I have the following table:
CREATE TABLE `visitors_table` (
`ID` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`visitor_ip` VARCHAR(32) NULL,
`visitor_browser` VARCHAR(255) NULL,
`visitor_hour` SMALLINT(2) NOT NULL DEFAULT '00',
`visitor_minute` SMALLINT(2) NOT NULL DEFAULT '00',
`visitor_date` DATE NOT NULL,
`visitor_day` SMALLINT(2) NOT NULL,
`visitor_month` SMALLINT(2) NOT NULL,
`visitor_year` SMALLINT(4) NOT NULL,
`visitor_page` VARCHAR(255) NULL
);
The following query gets the visitors per day:
"SELECT visitor_date FROM visitors_table WHERE visitor_date = CURDATE()";
Now I want output the data hourly. See this example:
Day Year Hours Clicks
July 4, 2011 00:00:00 4
July 4, 2011 01:00:00 12
July 4, 2011 02:00:00 75
July 4, 2011 03:00:00 27
and so on...
Could someone help me? I can't get clear with the output of the total visitors by hours for one day!
With the following query comes only this result:
SELECT visitor_date, count(*) FROM visitors_table WHERE visitor_date = CURDATE() GROUP BY visitor_hour
visitor_date count(*)
2013-08-31 4
2013-08-31 7
I need to get the results by hours like written as above! Where is my mistake or how can i show it with php?