简体   繁体   English

显示一天的mysqli查询每小时点击数

[英]Show hourly clicks of a mysqli query for one day

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? 我的错误在哪里或如何用php显示?

SELECT visitor_date, count(*) FROM visitors_table WHERE visitor_date = CURDATE() group by visitor_hour

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM