So I have this code to count the number of 'Guides' by counting the number of IDs on the table.
function getGuideCount() {
global $db;
$query = $db->query("SELECT COUNT(id) AS count FROM kk_hq_guides ");
$fetch = $query->fetchAll(PDO::FETCH_ASSOC);
return $fetch;
}
I am returning the value to a vardump and I am getting this:
array(1) { [0]=> array(1) { ["count"]=> string(2) "36" } } Array
This is correct, I have an array with the key 'Count' storing the amount of guides.
Problem comes when I try to print that value.
$guideCount=getGuideCount();
print($guideCount['count']);
results in the following error:
Notice: Undefined index: count in ... on line 130. (Line 130 is this: return $fetch; )
Big thanks in advance!