Jump to content

Automatic Position?


Darylt

Recommended Posts

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

<?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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.