Page 1 of 1

PHP Countdown

Posted: Fri Apr 22, 2011 10:29 am
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

Re: PHP Countdown

Posted: Fri Apr 22, 2011 10:40 am
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

Re: PHP Countdown

Posted: Fri Apr 22, 2011 11:07 am
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?

Re: PHP Countdown

Posted: Fri Apr 22, 2011 12:17 pm
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 ??

Re: PHP Countdown

Posted: Fri Apr 22, 2011 12:48 pm
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.

Re: PHP Countdown

Posted: Fri Apr 22, 2011 1:28 pm
by Celauran
Any reason you're not just running this from cron?

Re: PHP Countdown

Posted: Sat Apr 23, 2011 9:17 am
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.