Jump to content

RANK


cyrixware

Recommended Posts

Hello any idea how to create rank?

 

Mysql:

 

------------- Score ---- Rank -------------------

                    90            1

                    90            1

                    87            2 

------------||      ||---||    ||------------------

 

Thanks ;)

Link to comment
https://forums.phpfreaks.com/topic/93019-rank/
Share on other sites

Well you can't call a rank as it is dependent on Score so don't even store "rank"

instead do an Order By Query (by Score)

<?php
$q = "Select Score from `table` Order By Score DESC";
$r = mysql_query($q) or die(mysql_error()."<Br /><Br / >".$q);
if(mysq_num_rows($r) >0){
$i = 0;
echo "<table><tr><td>User</td><td>Score</td><td>Rank</td></tr>";
while($row = mysql_fetch_assoc($r)){
if($row['Score'] != $score){$i++;}
echo "<tr><td>".$row['Username']."</td><td>".$row['Score']."</td><td>".$i."</td></tr>";
$score =$row['Score'];
}
?>

Link to comment
https://forums.phpfreaks.com/topic/93019-rank/#findComment-476551
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.