[SOLVED] enumerate row and print in numeric order

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
fresh
Forum Contributor
Posts: 259
Joined: Mon Jun 14, 2004 10:39 am
Location: Amerika

[SOLVED] enumerate row and print in numeric order

Post by fresh »

Hey,

I'm trying to enumerate this row, the users names, according to the points row, in numeric order, i.e., highest to lowest, the highest being listed first and the lowest being listed last... could anyone show me what I should do to accomplish that... thanks :)

Code: Select all

$them=@mysql_query("select username from users") or die(mysql_error());
while($row = mysql_fetch_array($them))
{
echo "
<div style='border:#EFEFEF 1px solid;width:200;background:#FFFFFF;'>
&nbsp;<img src='http://blah.com/blah.gif'>&nbsp;&nbsp;
<a href='mypage.php' style='text-decoration:none'>
<font color=black>".$row['username']."</font></a>
</div>";
}
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Code: Select all

$them = @mysql_query("SELECT username FROM users ORDER BY points") or die(mysql_error());
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

If you want highest to lowest then you might want to add a DESC:
SELECT username FROM users ORDER BY points DESC
User avatar
fresh
Forum Contributor
Posts: 259
Joined: Mon Jun 14, 2004 10:39 am
Location: Amerika

yeah

Post by fresh »

works great, thanks alot :)
Post Reply