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 Link to comment https://forums.phpfreaks.com/topic/42261-solved-calculate-rank/ 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"; ?> Link to comment https://forums.phpfreaks.com/topic/42261-solved-calculate-rank/#findComment-205010 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! Link to comment https://forums.phpfreaks.com/topic/42261-solved-calculate-rank/#findComment-205016 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.