Given a table called "people" where names of people are associated to their city, I need to retrieve the number of people who come from the same city.
PEOPLE CITY John Baltimore David London Paula Baltimore Mark Baltimore Alex London My code is as follows:
$array_cities = array(); $query = "SELECT * FROM people"; $result = mysql_query($query); if ($result) { while ($record = mysql_fetch_array($result)) $array_cities[] = $record['city']; } print_r(array_count_values($array_cities)); And what I get in my browser is:
Array ( [Baltimore] => 3 [London] => 2 ) The output is correct, but it is not graphically good. What I would want is something like:
Baltimore => 3 London => 2 Are there any other options to get it?