Code: Select all
$result = mysql_query("SELECT `name` FROM `people` ORDER BY `age` DESC");Is there any simple way to determine which rank (X-oldest person) an entry with a certain `name` will be? Example, find out that "Bob" is the 32nd-oldest person? The only way I could think of doing it is like this:
Code: Select all
$i = 1;
while ($current_person = mysql_fetch_array($result))
{
if ($current_person['name'] == "Bob")
break;
$i++;
}
print "Bob is the $i oldest person";