The following SQL PHP code shows count of country from database and displays it in a table. Here is the code
foreach($dbh->query('SELECT country,COUNT(*)
FROM data_able
GROUP BY country') as $row) { $array = array();
echo "<tr>";
echo "<td>" . $row['country'] . "</td>";
echo "<td>" . $row['COUNT(*)'] . "</td>";
echo "</tr>";
}
Here is the result
I would like to use the data as $country1
and $count1
.
For example $country1
will output "Andorra" and $country5
will be "India".
and $count5
should give "25" as result. How can I do that ?