List hits per hour from a MySQL table
- by Axel
I am trying to work out the hits per hour from a database. Data basically is stored as follows (with other columns) :
Table Name: Hits
============================
VisitorIP TIMESTAMP
----------------------------
15.215.65.65 123456789
I want to display total hits per hour (within the last 6 hours ) including the hours that has no hits.
Example of the output:
// Assuming now : 21:00
21:00 - 0 hits
20:00 - 1 hits
19:00 - 4 hits
18:00 - 0 hits
17:00 - 2 hits
16:00 - 3 hits
i would love to get the data as array, Please note that the stored date is in UNIX time stamp format. and there may be some hours without any hits!
Thanks