sandrob57 Posted March 11, 2007 Share Posted March 11, 2007 I need to display the rank of my players. The rank is based on this row: c_strength What would I use to count their rank, ie: Rank: 54 of 5,231 Quote Link to comment Share on other sites More sharing options...
Barand Posted March 11, 2007 Share Posted March 11, 2007 <?php $sql = "SELECT COUNT(*) FROM players"; $res = mysql_query($sql) $total_players = mysql_result($res, 0); //for a particular player identified by $player_id $sql = "SELECT COUNT(*) FROM players WHERE c_strength > (SELECT c_strength FROM players WHERE player_id = '$player_id'); $res = mysql_query($sql) $rank = mysql_result($res, 0) + 1; echo "Rank: $rank of $total_players"; ?> Quote Link to comment Share on other sites More sharing options...
sandrob57 Posted March 11, 2007 Author Share Posted March 11, 2007 Never mind, i got it to work. Thanks so much! 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.