RON_ron Posted September 6, 2010 Share Posted September 6, 2010 statez : I need to sort the results from the high score to the low score. $query = "SELECT statez, COUNT(statez)FROM distributors GROUP BY statez"; $results = mysql_query($query); $returnS=""; while($line = mysql_fetch_array($results)) { $returnS.= $line['COUNT(statez)'].",,".$line['statez'].",,,"; } echo $returnS; mysql_close($link); ?> Quote Link to comment https://forums.phpfreaks.com/topic/212659-sort-by-the-result-value/ Share on other sites More sharing options...
sasa Posted September 6, 2010 Share Posted September 6, 2010 $query = "SELECT * FROM (SELECT statez, COUNT(statez) AS c FROM distributors GROUP BY statez) AS r ORDER BY c DESC"; Quote Link to comment https://forums.phpfreaks.com/topic/212659-sort-by-the-result-value/#findComment-1107821 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.