displays a message for every 30 minutes

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
sobha
Forum Commoner
Posts: 56
Joined: Wed Jul 15, 2009 9:08 pm

displays a message for every 30 minutes

Post 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
marty pain
Forum Contributor
Posts: 105
Joined: Thu Jun 11, 2009 5:32 am
Location: Essex

Re: displays a message for every 30 minutes

Post 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.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: displays a message for every 30 minutes

Post 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.
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Re: displays a message for every 30 minutes

Post 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.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: displays a message for every 30 minutes

Post 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.
Post Reply