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); ?> 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"; 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
Archived
This topic is now archived and is closed to further replies.