How to print month name from MySQL timestamp count in PHP? -
How to print month name from MySQL timestamp count in PHP? -
i count article view timestamp month using json output. have code :
$value = array(); $stats = access::fetch("select count(*) id news_stats grouping year(date), month(date)"); foreach($stats $key => $value){ $rows2[] = $value['id']; } echo json_encode($rows2);
output : note: count month each month
["1","6"]
i need print month name ouput this:
["january","june"]
how can in print month name ? menaig is: 1 , 6
count month?
try :
$value = array(); $stats = access::fetch("select id, year(from_unixtime(date)) `year`, monthname(from_unixtime(date)) `month`, count(*) id news_stats grouping `year`, `month` order `year` desc, `month`"); foreach($stats $key => $value){ $rows2[] = $value['month']; } echo json_encode($rows2);
output :
["june","august"]
enjoy!!
php mysql
Comments
Post a Comment