Generate daily basis by month report in table format

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
little_girl
Forum Newbie
Posts: 20
Joined: Tue Oct 13, 2009 5:11 am

Generate daily basis by month report in table format

Post by little_girl »

I would like to generate a daily basis by month report in table format. The report will show the sum of user for each category in daily basis based on the selected month from drop-down list.

Table layout is as below:
Image

In the query result that I get is as below:
Image

This is mysql query select statement:
SELECT DATE(DateCreated) AS sub_date, categoryID, COUNT(UserID) AS sub_users FROM Magazine WHERE YEAR(DateCreated)=YEAR(CURDATE()) AND MONTH(DateCreated)=$m GROUP BY DATE(DateCreated), CategoryID

I would like know how to show a table layout as above based on the query result that I got and show 'Null' record as '0'. Can we use the mysql select statement to put the sum of users for each category into different column?

As for the information, CategoryID field consists of record where 1=Sport, 2=Entertainment, 3=Business.

Hope someone could help me out. Thanks in advance.
little_girl
Forum Newbie
Posts: 20
Joined: Tue Oct 13, 2009 5:11 am

Re: Generate daily basis by month report in table format

Post by little_girl »

Is there a way where I want show the sum of users per day for each category into different column?
little_girl
Forum Newbie
Posts: 20
Joined: Tue Oct 13, 2009 5:11 am

Re: Generate daily basis by month report in table format

Post by little_girl »

I found my solution. Thanks.
Post Reply