widget Posted June 15, 2007 Share Posted June 15, 2007 Site uses php and MySQL I have a game where the users score is submitted into a table that is used for lots of games. The best explaination is to see for yourself. Here is the output Top Scores 1. pistoche - 2727 2. pistoche - 2580 3. pistoche - 2566 4. pistoche - 2478 5. pistoche - 2431 6. pistoche - 2429 7. pistoche - 2399 8. pistoche - 2399 9. pistoche - 2397 10. pistoche - 2344 11. pistoche - 2310 12. pistoche - 2295 13. pistoche - 2176 14. pistoche - 2175 15. pistoche - 2168 16. pistoche - 2144 17. pistoche - 2121 18. pistoche - 2120 19. Lolly Pop Chicka - 2070 20. pistoche - 2062 21. j e f f g o r d o n - 2045 22. pistoche - 2041 23. pistoche - 2040 24. pistoche - 2031 25. pistoche - 2029 26. j e f f g o r d o n - 2023 27. Lolly Pop Chicka - 2019 and here is the code $game_name = bubblepop; mysql_query("INSERT INTO highscores (game, user, game_name, score, daily) VALUES ('1', '$userid', '$game_name', '$score', '$datestamp')"); $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++; } $yourTotalScore = fetch("SELECT score FROM highscores WHERE game_name = 'bubblepop' AND game= '$game' AND user = '$userid'"); print "<p align=center><TABLE CELLSPACING=0 CELLPADDING=10 WIDTH=80%> <TR BGCOLOR=\"#F5E462\"> <TD> <CENTER> <B>Top Scores</B> </CENTER> </TD> </TR> <TR BGCOLOR=\"#FCFFDE\"> <TD valign=\"top\"> $top5 </TD> </TR> </TABLE> Is there a way to make it sort through the data to find a double up of a username and only display that usernames high score. So the output would be Top Scores 1. pistoche - 2727 2. Lolly Pop Chicka - 2070 3. j e f f g o r d o n - 2045 etc etc Quote Link to comment https://forums.phpfreaks.com/topic/55733-high-scores-list-display-username-only-once/ Share on other sites More sharing options...
per1os Posted June 15, 2007 Share Posted June 15, 2007 Distinct and/or group by in the SQL clause. www.google.com will help you get what you want. Quote Link to comment https://forums.phpfreaks.com/topic/55733-high-scores-list-display-username-only-once/#findComment-275366 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.