$res=mysql_query("SELECT color, count(*) total FROM colores GROUP BY 1 ORDER BY 2 desc" ,$con); while ($reg=mysql_fetch_assoc($res)) { echo $reg['color'] . ' : ' . $reg['total'] .'<br>' ; } mysql_close($con);