MDanz Posted April 2, 2011 Share Posted April 2, 2011 i did this but then realised it won't total the `rating` for a DISTINCT username. How can i change it so that it totals the rating for a username? $getuser = mysql_query("SELECT DISTINCT username, rating FROM block WHERE category='$category' ORDER BY `rating` DESC",$this->connect); while ($row = mysql_fetch_assoc($getuser)){ $theuser = ucfirst($row['username']); $rating = $row['rating']; echo "<div class='leaderboard'><ul><li><a href='profile.php?user=$theuser'>$theuser</a></li><li>$rating</li></ul></div>"; } Quote Link to comment https://forums.phpfreaks.com/topic/232494-mysql-leaderboard-help/ Share on other sites More sharing options...
The Little Guy Posted April 2, 2011 Share Posted April 2, 2011 Try this: SELECT username, sum(rating) as rating FROM block WHERE category='$category' group by username ORDER BY `rating` DESC Quote Link to comment https://forums.phpfreaks.com/topic/232494-mysql-leaderboard-help/#findComment-1195884 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.