TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-07-2009, 02:41 PM   #1 (permalink)
The Contributor
 
russellharrower's Avatar
 
Join Date: Jul 2009
Posts: 80
Thanks: 13
russellharrower is on a distinguished road
Default 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.
russellharrower is offline  
Reply With Quote
Old 12-07-2009, 07:03 PM   #2 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

What stage are you at right now?
Salathe is offline  
Reply With Quote
Old 12-07-2009, 07:50 PM   #3 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

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?
delayedinsanity is offline  
Reply With Quote
Old 12-08-2009, 01:16 AM   #4 (permalink)
The Contributor
 
russellharrower's Avatar
 
Join Date: Jul 2009
Posts: 80
Thanks: 13
russellharrower is on a distinguished road
Default

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
russellharrower is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Timezone Class: Dealing with Timezones the Proper Way Wildhoney General 2 01-10-2011 11:01 PM
Save time with this PHP/MySQL Code generator TheDevShop Libraries & Extensions 4 06-07-2008 12:57 AM
Two Different Ways to Format the Time CMellor Tips & Tricks 0 09-24-2007 11:12 PM
Script Execution Time Class Wildhoney Script Giveaway 2 09-14-2007 11:36 PM
Calculating the Execution Time Wildhoney Tips & Tricks 0 09-14-2007 11:14 PM


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

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design