widget Posted July 4, 2007 Share Posted July 4, 2007 I need some help with my high score table. Currently it outputs the top 50 scores but not sorted by highest per user. EXAMPLE OF OUTPUT Top Scores 1. Lolly Pop Chicka - 1485 2. Lolly Pop Chicka - 1102 3. Lolly Pop Chicka - 1024 4. Pistoche - 741 5. Pistoche - 727 CURRENT CODE $x = 1; $findTop5 = mysql_query("SELECT * FROM highscores WHERE game_name = 'bubblepop' ORDER BY score DESC LIMIT 50"); while ($getTop5 = mysql_fetch_array($findTop5)) { $getUsername = fetch("SELECT username,display_name,premium,display_prem FROM members2 WHERE game = '1' AND id = '$getTop5[user]'"); if (($getUsername[premium] == 1) AND ($getUsername[display_prem])) { $getUsername[display_name] = $getUsername[display_prem]; } $top5 .= "$x. <A href=user_profile.php?game=$game&user=$getUsername[username]>$getUsername[display_name]</a> - $getTop5[score]<br>"; $x++; } I need to to output like this Top Scores 1. Lolly Pop Chicka - 1485 2. Pistoche - 741 I've had a go at grouping but couldnt get it to work. If someone could please show me a code example, that would be great!! Thank you in advance for any help - its much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/58401-sorting-array-need-help-please/ Share on other sites More sharing options...
RichardRotterdam Posted July 4, 2007 Share Posted July 4, 2007 in your $findTop5 query try to use a right join while preforming a select on both highscores and members2. a natural join might work good to not sure though Quote Link to comment https://forums.phpfreaks.com/topic/58401-sorting-array-need-help-please/#findComment-289574 Share on other sites More sharing options...
widget Posted July 4, 2007 Author Share Posted July 4, 2007 Sorry, m a newb. What is a right join? Quote Link to comment https://forums.phpfreaks.com/topic/58401-sorting-array-need-help-please/#findComment-289712 Share on other sites More sharing options...
cooldude832 Posted July 4, 2007 Share Posted July 4, 2007 why not do $getUsername = fetch("SELECT username,display_name,premium,display_prem FROM members2 WHERE game = '1' AND id = '$getTop5[user]' ORDER BY Score "); Quote Link to comment https://forums.phpfreaks.com/topic/58401-sorting-array-need-help-please/#findComment-289714 Share on other sites More sharing options...
widget Posted July 7, 2007 Author Share Posted July 7, 2007 Sorry but I dont understand where I should put that line of code or how to implement it. Could you please show me Quote Link to comment https://forums.phpfreaks.com/topic/58401-sorting-array-need-help-please/#findComment-291948 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.