simonp Posted November 24, 2007 Share Posted November 24, 2007 Hi folks, I'm using: $sql = "SELECT * from $myTable ORDER BY `points` DESC LIMIT 5"; in a whileloop to display the top five scorers but would like to put their position next to the results (eg, 1, 2, 3, 4 and 5) Is there an easy way to do this? Cheers Simon Quote Link to comment Share on other sites More sharing options...
LordOrange Posted November 24, 2007 Share Posted November 24, 2007 I would define a variable at the beginning of the loop and set it to add on to that variable every loop and then just print it where you want it Quote Link to comment Share on other sites More sharing options...
hostfreak Posted November 24, 2007 Share Posted November 24, 2007 Try: <?php //sql //result $i = 1; while ($row= mysql_fetch_assoc($result)) { echo $i . ' ' . $row['column']; $i++; } ?> edit: which is basically doing what LordOrange said Quote Link to comment Share on other sites More sharing options...
simonp Posted November 24, 2007 Author Share Posted November 24, 2007 Thanks LordOrange and hostfreak - worked a treat! Cheers Simon Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.