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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.