Re: number on the quene, or how to get rank?

From: Date: Tue, 05 Apr 2005 17:08:46 +0000
Subject: Re: number on the quene, or how to get rank?
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-39119@lists.php.net to get a copy of this message
You could try something like this perhaps... SELECT score FROM highscores WHERE name = 'userD' then use the result of that to do this: SELECT COUNT(*) FROM highscores WHERE score > 2 rank would then be the result of the above query plus one. -philip On Tue, 5 Apr 2005 emre@vt.com.tr wrote:
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 (#39119) next »