Mario.C Mario.C - 4 months ago 9
MySQL Question

MySQL in PHP can't get values that are equal

I'm trying to make a TOP users of my website, but that problem that i have is if one 2 or more users have the same amount of won games only the 1st result appear in the website.

Im using this code to search in the database:

$rs1 = mysql_query(SELECT won,steamid,name,avatar,games
FROM `users`
WHERE won <> 0
GROUP BY won DESC LIMIT 18);
while($row = mysql_fetch_array($rs1))
{ //AND HTML CODE HERE...}


can someone help me with this? i want to show all the users for example if they have the same number of won games it would show for example:

RANK - USER - WON
1 - NAME - 12
2 - NAME - 8
3 - NAME - 8
4 - NAME - 4


BTW i know that i should not use
mysql_query
but i can't do it in another way.

svn svn
Answer

Seems to me that your GROUP BY should be an ORDER BY

rs1 = mysql_query(SELECT won,steamid,name,avatar,games 
               FROM `users` 
               WHERE won <> 0 
               ORDER BY won DESC LIMIT 18); 

If that does not work please share the table structure