number on the quene, or how to get rank?

From: Date: Tue, 05 Apr 2005 16:39:29 +0000
Subject: number on the quene, or how to get rank?
Groups: php.db 
Request: Send a blank email to php-db+get-39117@lists.php.net to get a copy of this message
hi everyone, I' ve a table named as 'highscores', inserting result scores of a game and players name(each player can only play once) what I want to do is to get the "current rank" of a player over a listing of all rows ordered by scores desc. id -name - score 1 - userA - 8 2 - userB - 3 3 - userC - 10 4 - userD - 2 5 - userE - 7 here is how I figured out this thing: $sql=mysql_query(SELECT userD FROM highscores ORDER BY score DESC); $i=1; while($scorelist=mysql_fetch_array($sql)) { if($scorelist[name]=='userD') echo "your rank is: $i "; $i++; } how can I get a specific row's "formatted no" through all affected rows? Is there a MySQL command doing this job that i am unaware of? thx in adv.

« previous php.db (#39117) next »