TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Time different PHP/MYSQL (http://www.talkphp.com/general/5155-time-different-php-mysql.html)

russellharrower 12-07-2009 02:41 PM

Time different PHP/MYSQL
 
Hi guys,
I am trying to figure out how to do the following

I want to get the last 3 entries in the database
get the time, then i need to find out if all 3 of them have been added in the last 3minutes.

If anyone can help that would be great.

Salathe 12-07-2009 07:03 PM

What stage are you at right now?

delayedinsanity 12-07-2009 07:50 PM

mysql Code:
SELECT one, two, three FROM `table` WHERE date_field >= DATE_SUB( NOW(), INTERVAL -3 minute ) LIMIT 3

The limit is optional of course, you could easily pull everything from that range and see how many rows you got in total. Or you could leave the date functionality out and just pull the last three rows, and check their timestamps. Or you could always do the date arithmetic on the PHP side too... and you could... well there's almost 50 or so options for how to do this. I think Salathe is on the right track, where are you at with it?

russellharrower 12-08-2009 01:16 AM

I have the MYSQL set up.

The goal is to make sure the issuer does not bombard the system and request MP3 files. over and over again.

they access the files via the same page http://www.example.com/ad.php
and the ad.php file returns the current ad for that station.

The station is only allowed to play a max of 3 ads in 3 minutes.
Each ad is 30seconds long.

Hope that helps


All times are GMT. The time now is 02:20 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0