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 Quote Link to comment 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']; } ?> Quote Link to comment Share on other sites More sharing options...
cyrixware Posted February 26, 2008 Author Share Posted February 26, 2008 Thanks dude! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.