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 Link to comment https://forums.phpfreaks.com/topic/62426-automatic-position/ 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); } ?> Link to comment https://forums.phpfreaks.com/topic/62426-automatic-position/#findComment-310702 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.