timmah1 Posted June 19, 2008 Share Posted June 19, 2008 Does anybody know where I can find a tutorial or if somebody knows how to make a ranking system? I'm trying to make a ranking system and show the top 20 players, and if you're not in the top 20, it shows your rank below the top 20. I can't figure out how to make one, and I can't find a tutorial or anything for user ranking, only page ranking. Any help would be appreciated. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/110974-solved-player-ranking-system/ Share on other sites More sharing options...
ober Posted June 19, 2008 Share Posted June 19, 2008 What kind of ranking are you referring to? What values are you storing? Link to comment https://forums.phpfreaks.com/topic/110974-solved-player-ranking-system/#findComment-569340 Share on other sites More sharing options...
timmah1 Posted June 19, 2008 Author Share Posted June 19, 2008 Player Rankings. The top 20 players of the game. I'm storing values of money. It's an online game, and the person with the most money should be on top obviously, and so forth down to 20. If your ranking isn't in the top 20, it should still show your ranking, but below the top 20. Link to comment https://forums.phpfreaks.com/topic/110974-solved-player-ranking-system/#findComment-569347 Share on other sites More sharing options...
ober Posted June 19, 2008 Share Posted June 19, 2008 SELECT * FROM players ORDER BY money DESC Link to comment https://forums.phpfreaks.com/topic/110974-solved-player-ranking-system/#findComment-569360 Share on other sites More sharing options...
timmah1 Posted June 19, 2008 Author Share Posted June 19, 2008 I am currently doing that $worth="SELECT * FROM profile WHERE tour = '$tour_name' ORDER BY worth DESC LIMIT 20"; But I need to show the ranking(1,2,3, etc...) beside the players name, and I cannot figure out how to do that Link to comment https://forums.phpfreaks.com/topic/110974-solved-player-ranking-system/#findComment-569361 Share on other sites More sharing options...
DarkWater Posted June 19, 2008 Share Posted June 19, 2008 Just make an incrementing variable that you output inside the while loop: $count = 1; while ($row = mysql_fetch_assoc($result)) { echo "$count: {$row['name']}"; $count++; } Something like that. Link to comment https://forums.phpfreaks.com/topic/110974-solved-player-ranking-system/#findComment-569366 Share on other sites More sharing options...
ober Posted June 19, 2008 Share Posted June 19, 2008 Just add a counter variable to the while loop: $i = 1; while($row = mysql_fetch_array($result)) { echo $i . " " . $blah; $i++; } Link to comment https://forums.phpfreaks.com/topic/110974-solved-player-ranking-system/#findComment-569367 Share on other sites More sharing options...
timmah1 Posted June 19, 2008 Author Share Posted June 19, 2008 I'm using this $i = 1; while($r=mysql_fetch_assoc($result)){ echo $i . " " . $r['username']; $i++; } but it doesn't produce any number beside the username Link to comment https://forums.phpfreaks.com/topic/110974-solved-player-ranking-system/#findComment-569375 Share on other sites More sharing options...
timmah1 Posted June 19, 2008 Author Share Posted June 19, 2008 nevermind, I just realized i had this twice while($r=mysql_fetch_assoc($result)){ after deleting one of them, it works perfect now Thanks Link to comment https://forums.phpfreaks.com/topic/110974-solved-player-ranking-system/#findComment-569378 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.