[PHP] Leaderboard problem?[PHP]
Hey for my recent project HabblowSoft i have started the leaderboard for the games heres my code
Code:
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="38%"><div align="center"><strong>Display Name</strong></div></td>
<td width="42%"><div align="center"><strong>Gameing Points</strong></div></td>
</tr>
<?php
$ranking_query = mysql_query("SELECT gameingpoints, displayname FROM users ORDER BY gameingpoints LIMIT $limit");
while($ranking = mysql_fetch_assoc($ranking_query)) {
?>
<tr>
<td><div align="center"><?php echo $ranking['displayname']; ?></div></td>
<td><div align="center"><?php echo $ranking['gameingpoints']; ?></div></td>
</tr>
<?php
}
?>
</table>
i need it to order by gameingpoints in order for highest to lowest please it echos them out it just dosent order them.
Please help
Regards Nick.
Re: [PHP] Leaderboard problem?[PHP]
PHP Code:
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="38%"><div align="center"><strong>Display Name</strong></div></td>
<td width="42%"><div align="center"><strong>Gameing Points</strong></div></td>
</tr>
<?php
$ranking_query = mysql_query("SELECT `gameingpoints, displayname` FROM `users` ORDER BY `gameingpoints` DESC LIMIT `$limit`");
while($ranking = mysql_fetch_assoc($ranking_query)) {
?>
<tr>
<td><div align="center"><?php echo $ranking['displayname']; ?></div></td>
<td><div align="center"><?php echo $ranking['gameingpoints']; ?></div></td>
</tr>
<?php
}
?>
</table>
That should do.
I've just changed your query so it orders DESC (descending, e.g: 3, 2, 1) instead of ASC (ascending, default in mysql, e.g: 1, 2, 3).
Re: [PHP] Leaderboard problem?[PHP]
yes i tryed DESC
Edit: Same Problem :S
its dispalying like this:
Display Name Gameing Points
animalsrule 62
dethklok 106
monsters 1003
Nickster 1002
Nick 100
Roamer 0
However it should display like this:
Display Name Gameing Points
monsters 1003
Nickster 1002
dethklok 106
Nick 100
animalsrule 62
Roamer 0
Re: [PHP] Leaderboard problem?[PHP]
That's what DESC should do.. what kind of variable is `gameingpoints`?
Make sure it's an integer.
Re: [PHP] Leaderboard problem?[PHP]
ahh thanks fixed now :) i forgot about that! thanks eva so much