cyrixware Posted February 26, 2008 Share Posted February 26, 2008 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 More sharing options...
cooldude832 Posted February 26, 2008 Share Posted February 26, 2008 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 More sharing options...
cyrixware Posted February 26, 2008 Author Share Posted February 26, 2008 Thanks dude! Link to comment https://forums.phpfreaks.com/topic/93019-rank/#findComment-476552 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.