Jump to content

Counter per Hour...


SharkBait

Recommended Posts

Not sure how I would set up for something like this.


I have a site where users enter information in and it gets time stamped to a MySQL Database.

What I want to do is display to the users how many entries are entered at any given time over the course of an hour.

So an Entries Per Hour kinda deal.

Would I make the query look like:

[code]
SELECT count(*) FROM myTable WHERE date_entered >= AN AN HOUR AGO FROM NOW
[/code]

Not sure if I would use SQL's time functions or PHP's Time functions, and how :)

Thanks
Link to comment
https://forums.phpfreaks.com/topic/12104-counter-per-hour/
Share on other sites

You could do the whole day with

[code]$res = mysql_query("SELECT DATE_FORMAT(tstamp, '%h %p') as hour, COUNT(*) as total
                FROM tablename
                GROUP BY hour") or die(mysql_error());
while (list($hour, $total) = mysql_fetch_row($res))  {
    echo "$hour : $total<br>";
}[/code]
Link to comment
https://forums.phpfreaks.com/topic/12104-counter-per-hour/#findComment-46094
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.