Hello -
I am looking to build a small leaderboard of such for my website which has a couple of games on it.
What im looking to do, is to retrieve the record, which shows which user has the most awards (most highscores). He who has the most, is the king of the arcade.
What im looking to do, is to display the top -3- users
IE:
1st place Gold
2nd place Silver
3rd place Bronze
I have it partially down, but im lost, and my code isnt the best. Can someone please have a look see and help me out? Im losing too much hair. 😃
Heres where im at:
$mosthighscores = $DB_site->query("SELECT games.highscorerid, user.username, user.userid FROM " . TABLE_PREFIX . "games AS games
LEFT JOIN " . TABLE_PREFIX . "user AS user ON user.userid = games.highscorerid");
while ($besthigh = $DB_site->fetch_array($mosthighscores)) {
$mh[$besthigh[highscorerid]]['count'] = $mh[$besthigh[highscorerid]]['count'] + 1;
if ($mh[$besthigh[highscorerid]]['count']<$mosthigh) { }
else {
if ($mh[$besthigh[highscorerid]]['count']>$mosthigh) {
$mosthigh = $mh[$besthigh[highscorerid]]['count'];
$mhsuser = $besthigh[highscorerid];
$mhsarray = "";
$mhsusername = $besthigh[username];
} else {
$mhsuser = $besthigh[highscorerid];
$mhsarray .= $mhsusername.", ".$besthigh[username];
$mhsusername = "";
}
}
}
$DB_site->free_result($mosthighscores);
This works ok for finding 1 user ... And it works ok for checking to see if 2 users have the same number of awards, but thats it.
Thanks for any help/assistance!