...

View Full Version : Is this a job for PHP or JavaScript or Both??



srule_
10-22-2007, 11:38 PM
I need a Timer that counts down from 1hr, Once it gets to zero I need an event to happen (ex: output hello) then it will restart in an endless loop.

It thould be in the following format:

1:00:00
59:59
59:58
ext....

gnomeontherun
10-22-2007, 11:47 PM
JavaScript will allow you to count on a local computer's browser - so somebody will need to be viewing the page during the countdown for the event to occur. Javascript gives you power to do stuff on the client side. PHP gives you power to do stuff on the server side. If you need something to occur every hour regardless of who is looking at the site or how long they are, use a cron job with PHP.

It really depends on what the timer is linked to, what event you want to occur, and if its client or server side.

srule_
10-22-2007, 11:50 PM
yes, i want the event to happen even if nobody is on the site.
so i guess it is php

rfresh
10-23-2007, 12:48 AM
I you just need something to happen once an hour, a cron job script could do this. Are you on a Linux server? If so, then you can write a PHP script and add it to your crontab to execute once an hour.

If you need the webpage to show an active count down, then you will need to do this using Javascript - when JS count down reaches 0 it will call a PHP script on your server to do something and then call the html web page again which will start the visable count down again.

gnomeontherun
10-23-2007, 09:15 PM
Here is a good introduction to cron jobs

http://www.sitepoint.com/article/introducing-cron

If you aren't on Linux or have access to cron jobs, you can have pseudo cron jobs

http://www.bitfolge.de/pseudocron-en.html

srule_
10-24-2007, 02:15 AM
thanks for the help, I'm gonna look into it now :-)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum