PHP Countdown

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tonchily
Forum Commoner
Posts: 54
Joined: Thu Sep 02, 2010 10:44 am

PHP Countdown

Post by tonchily »

Hello guys,

I have a countdown that is counting from 24:00:00 to obviously 00:00:00. I need it to run a specific php file once it gets to zero. Anyone knows how may I accomplish this? I suppose it's pretty easy but I don't have an idea right now.

About the countdown start time - it's been stored in Mysql as date time, but it could be also stored as timestamp if that would make it possible to happen.
Thanks a lot,

Toni
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: PHP Countdown

Post by fugix »

you could store the countdown timestamp into a variable and then set an if function for when that variable is = to 00:00:00
tonchily
Forum Commoner
Posts: 54
Joined: Thu Sep 02, 2010 10:44 am

Re: PHP Countdown

Post by tonchily »

fugix wrote:you could store the countdown timestamp into a variable and then set an if function for when that variable is = to 00:00:00
Yeah but that means the script would run when someone visits that page. What if there's noone online?
ayazhaider
Forum Newbie
Posts: 5
Joined: Fri Apr 22, 2011 11:18 am

Re: PHP Countdown

Post by ayazhaider »

yes, and that visitor view the webpage you want to show after the countdown reached 00:00:00 ...
what do u want to do ??
tonchily
Forum Commoner
Posts: 54
Joined: Thu Sep 02, 2010 10:44 am

Re: PHP Countdown

Post by tonchily »

ayazhaider wrote:yes, and that visitor view the webpage you want to show after the countdown reached 00:00:00 ...
what do u want to do ??
Once the countdown has reached 00:00:00, I want to run file "update.php" which generates number between 1 and 100 and then use that $generated_number in query like "UPDATE users SET premium='1' WHERE user_id='$generated_number'"

Hope I was more clear now.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: PHP Countdown

Post by Celauran »

Any reason you're not just running this from cron?
tonchily
Forum Commoner
Posts: 54
Joined: Thu Sep 02, 2010 10:44 am

Re: PHP Countdown

Post by tonchily »

Celauran wrote:Any reason you're not just running this from cron?
Because I can't predict the time countdown will start and that way I don't know when will it end. Start of the countdown is dynamical also.
Post Reply