Reputation: 371
I'm trying to get a count of records grouped by a monthly basis from the entire table.
So for example I need:
June: 20 OR 6: 20
Jan: 18 or 1: 18
So far I have
$mquery = $db->query('SELECT MONTH(FROM_UNIXTIME(dateline)),YEAR(FROM_UNIXTIME(dateline)),
COUNT(*) as count FROM '.TABLE_PREFIX.'posts GROUP BY MONTH(FROM_UNIXTIME(dateline))');
$count = $db->fetch_array($mquery);
print_r($count);
Which returns only the current month and the count for the current month I need to output all months it can find as well as the count
Upvotes: 1
Views: 58
Reputation: 72299
You can do it in 2 ways:-
$count = $db->fetch_all($mquery);
print_r($count);
OR
while($count = $db->fetch_array($mquery)){
print_r($count);
}
Upvotes: 3