Page 1 of 1

[SOLVED] enumerate row and print in numeric order

Posted: Sun Jul 18, 2004 1:42 am
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>";
}

Posted: Sun Jul 18, 2004 1:46 am
by d3ad1ysp0rk

Code: Select all

$them = @mysql_query("SELECT username FROM users ORDER BY points") or die(mysql_error());

Posted: Sun Jul 18, 2004 1:51 am
by markl999
If you want highest to lowest then you might want to add a DESC:
SELECT username FROM users ORDER BY points DESC

yeah

Posted: Sun Jul 18, 2004 2:14 am
by fresh
works great, thanks alot :)