Hope the title isn't too off putting!
Anyway I am having trouble getting the following to display what I want correctly. Here's the code then I'll explain;
Now a little background re the DB. Table 'leaderboard' contains a field called 'board'. On each board peole record their game results i.e. wins.
I am trying to list who has the most wins out of ALL of the boards. At the moment the While loop is displaying in DESC order the wins in a board, THEN it moves onto the next board and does the same. I want it to list who has the most wins over ALL the boards. I'm in smelling distance but just can't figure the logic of the loop.
Hope someone can understand all that to give some help.
Thanks.
Anyway I am having trouble getting the following to display what I want correctly. Here's the code then I'll explain;
Code:
$sql = "SELECT board FROM leaderboard";
$result = mysql_query($sql);
while($board = mysql_fetch_array($result, MYSQL_NUM))
{
$query = "SELECT $board[0].rank, users.username, $board[0].W FROM users, $board[0] WHERE users.id = $board[0].id ORDER BY W DESC LIMIT 50";
$result2 = @mysql_query ($query);
while ($row = mysql_fetch_array($result2, MYSQL_NUM))
{echo "<tr><td align=\"center\">$row[0]</td><td align=\"center\">$row[1]</td>
<td align=\"center\">$row[2]</td><td align=\"center\">$board[0]</td></tr>";
}
}
echo '</table>';
Now a little background re the DB. Table 'leaderboard' contains a field called 'board'. On each board peole record their game results i.e. wins.
I am trying to list who has the most wins out of ALL of the boards. At the moment the While loop is displaying in DESC order the wins in a board, THEN it moves onto the next board and does the same. I want it to list who has the most wins over ALL the boards. I'm in smelling distance but just can't figure the logic of the loop.
Hope someone can understand all that to give some help.
Thanks.