Darylt Posted July 30, 2007 Share Posted July 30, 2007 I have a basic table/database set up to record a persons name, location, the number of miles travelled and their position in a race. At the moment all of these fields have to be entred manually when you wish to update them. Is there a way to automatically assign a position? (i.e. the person who has travelled the most number of miles 1st - least nth? Many Thanks Quote Link to comment Share on other sites More sharing options...
Barand Posted July 30, 2007 Share Posted July 30, 2007 <?php $sql = "SELECT name,miles FROM table ORDER BY miles DESC"; $res = mysql_query($sql) or die (mysql_error()."<p>$sql</p>"); $pos = 0; while (list ($name,$mls) = mysql_fetch_row($res)) { printf ('%d : %s (%d)<br/>', ++$pos, $name, $mls); } ?> 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.