View Single Post
Old 10-20-2008, 07:35 PM   #2 (permalink)
sketchMedia
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

The sql doesnt seem to be the problem, although you may want to change it to DESC in order to get the most frequent first.

There are some errors in you script, you have not passed mysql_fetch_array a valid result link.
PHP Code:
    $q mysql_query("SELECT COUNT(`id`) AS freq, `name` FROM `table` GROUP BY `name` ORDER BY freq DESC");
    
    echo 
'<ul>';
    while(
$fetch mysql_fetch_array($q)) {
        echo 
'<li>'.$fetch["name"].'</li>';
    }
    echo 
'</ul>'
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote