slyte33 Posted December 23, 2009 Share Posted December 23, 2009 I am trying to get what position a player is in for something, for example: Player - Level: 100 (6th) Gold: 1,394,289 (109th) My players are stored in a table named 'players'; this is where all of their information is kept. I've seen it before, but Im having a hard time figuring out how to do it. All help is appreciated, thanks Link to comment https://forums.phpfreaks.com/topic/186173-getting-high-score-place-for-game/ Share on other sites More sharing options...
Buddski Posted December 23, 2009 Share Posted December 23, 2009 Can you show us a table layout with some sample data and how you want it displayed? Link to comment https://forums.phpfreaks.com/topic/186173-getting-high-score-place-for-game/#findComment-983228 Share on other sites More sharing options...
slyte33 Posted December 23, 2009 Author Share Posted December 23, 2009 Can you show us a table layout with some sample data and how you want it displayed? Im not sure what you mean, to explain it better i just want to basically display what place a player is on on the high scores. Link to comment https://forums.phpfreaks.com/topic/186173-getting-high-score-place-for-game/#findComment-983231 Share on other sites More sharing options...
Buddski Posted December 23, 2009 Share Posted December 23, 2009 So you just need to pull it out of the database? SELECT `players_high_score_ranking` FROM `players` WHERE player = 'whatever' ? players_high_score_ranking probably isnt the field name but you get the idea.. Link to comment https://forums.phpfreaks.com/topic/186173-getting-high-score-place-for-game/#findComment-983236 Share on other sites More sharing options...
slyte33 Posted December 26, 2009 Author Share Posted December 26, 2009 So you just need to pull it out of the database? SELECT `players_high_score_ranking` FROM `players` WHERE player = 'whatever' ? players_high_score_ranking probably isnt the field name but you get the idea.. Not exactly. I want to get what place a player is in, like if the results are: Player A - level 100 Player B - level 95 You - level 92 Player C - level 76 Then display: Level: 92 (3rd place) Link to comment https://forums.phpfreaks.com/topic/186173-getting-high-score-place-for-game/#findComment-984310 Share on other sites More sharing options...
phpfan101 Posted December 26, 2009 Share Posted December 26, 2009 This should give you what you want <?php $your_cash = "players_cash_value"; $others_cash = "dbtablnameforcash"; $rankresult = mysql_query("SELECT * FROM `players` WHERE `".$others_cash."` > ".$your_cash.""); $rankresult2 = mysql_num_rows($rankresult); $your_cash = $rankresult2 + 1; echo "Your ranked number ".$your_cash."!"; ?> Link to comment https://forums.phpfreaks.com/topic/186173-getting-high-score-place-for-game/#findComment-984312 Share on other sites More sharing options...
Stieny Posted December 27, 2009 Share Posted December 27, 2009 This is what I use for my rankings: <?php $result = mysql_query("SELECT * FROM users ORDER BY score desc") $i=1; while($row = mysql_fetch_array($result)) { echo "<tr><td>"; echo $i; echo "</td><td>"; echo $row['player_name']; echo "</td><td>"; echo number_format($row['score']); $i++; } ?> Link to comment https://forums.phpfreaks.com/topic/186173-getting-high-score-place-for-game/#findComment-984358 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.