I have this MySQL
selection query :
SELECT country, COUNT(*)
FROM $database
GROUP BY country
The output is an associative array with many rows and two columns: [country]
,[COUNT(*)]
Now I would like to print them out all BUT with
if (count($results) > 0) {
for($x = 0; $x < $arrlength; $x++) {
echo "country: " . $results[$x]->country. "<br>";
echo "reads: " . $results[$x]**[COUNT()]**. "<br>";
}
} else {
echo "0 results";
}
It seems the code does not recognize COUNT(*)
as column name and get no results. How can I access this second column values?