PHP MySql: print total post monthly archive -



PHP MySql: print total post monthly archive -

i need print total(count) news archive month of year(12 month) in json format :

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(*) id, year(date) `year`, month(date) `month`, monthname(date) `month_name`, `aticle` grouping `year`, `month`;

note: if dont have news in month print:0 i.e: "march:0","july:0".....

how can print this?!

you can utilize ifnull check if info not found should 0..

please seek query given below.

select ifnull(count(*),0) id, year(date) `year`, month(date) `month`, monthname(date) `month_name`,from `aticle`group `year`, `month`;

thanks

php mysql

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -