Hi,
I need to print Total(count) news archive by month of year(12 month) in json format like this :
Output:
["January:31","February:28","March:0","April:130","May:450","June:0","July:0","August:0","September:0","October:520","November:20","December:31"]
PHP CODE:
SELECT COUNT(*) AS id, y.yr, m.mon, m.mname
FROM (select distinct year(date) as yr from article) y cross join
(select distinct month(date) as mon, monthname(date) as mname from article) m left join
article a
on year(a.date) = y.yr and month(a.date) = m.mon
GROUP BY y.yr, m.mon;
// Simple Code For show all month
$value = array();
foreach($stats as $key => $value)
{
$rows2[] = $value['mname'];
}
echo json_encode($rows2);
output is :
[null,"February",null,"February"]
How do can in print my need output ?
my code is true ? if Yes, wht's my problem ?
Thanks for any help.