Page 1 of 1

displays a message for every 30 minutes

Posted: Thu Aug 27, 2009 9:39 pm
by sobha
In javascript we have
setInterval("alert(1)", 1000*60*30);to display a message for every 30 minutes

Similary is there any php function that displays a message for every 30 minutes.

Any other solutions ?

Thanks in advance

Re: displays a message for every 30 minutes

Posted: Fri Aug 28, 2009 10:28 am
by marty pain
Because web applications are stateless there isn't a way of scheduling tasks as such, but there are ways that can mimic that behaviour.

One answer -> If your site runs through a central page, and this page is used every time an action is performed on your application, then you can use that page to check the time of the action against a time stored in a file/database. If 30 minutes hasn't passed since the last action do nothing, if it has, display the message and reset the message to thirty minutes in the future.

Re: displays a message for every 30 minutes

Posted: Fri Aug 28, 2009 1:08 pm
by califdon
sobha wrote:In javascript we have
setInterval("alert(1)", 1000*60*30);to display a message for every 30 minutes

Similary is there any php function that displays a message for every 30 minutes.
No, because PHP does not continue to run after it has sent the page to the browser. Its job is done. Thus, you must do this sort of thing in the browser, which means you must use a client-side language like Javascript.

Re: displays a message for every 30 minutes

Posted: Sat Aug 29, 2009 9:50 am
by Bill H
You can run cron jobs on the (*nix) server at set intervals, but they would not be targeted at a particular browser.

Which points out the difference between a server side and client side language. It isn't just a different language, you are actually controlling two completely different environments. I think that point gets missed a lot.

Re: displays a message for every 30 minutes

Posted: Sat Aug 29, 2009 11:07 am
by califdon
Bill H wrote:Which points out the difference between a server side and client side language. It isn't just a different language, you are actually controlling two completely different environments. I think that point gets missed a lot.
Good way to present it.