Hi, I know sometimes javascript and php can be used together. Anyone know how to add a javascript set timeout to this? So that this php include will re-execute after so much time? Or is there a php refresh command I can add to this code itself, not the page. Thank you very much. Jen <?php include 'file.php'; ?>
Well there's the sleep() command, pretty much PHP's equivalent of setTimeout http://www.php.net/manual/en/function.sleep.php
one simple if not elegant way would be to create an iframe on page and have that iframe include a php file. every 5 seconds or whatever it would include a php file. You could control this with sleep. --- The only problem is that this won't do much good with what displays on the page. A longer approach is necessary to create a real auto updating php script which will actually display itself again on the page. The solution uses ajax and is quite long. Somebody i'll find the time to write out a tutorial for it on my site. --- Another way would be an auto refresher that just refreshes the page every 5 seconds or so, you could also do that within an iframe to prevent the entire site page from reloading. A problem with this is that in IE you get an annoying click every time you open a new page.
I think that a simple AJAX script to call the php file as whatever interval you need would be the best way to do it.
Refreshing the page won't work, already tried that on a faster timer and it affects the whole page too much, as well as seeing the browser load it at the bottom of the browser each time. If I try it with ajax will that keep the search engines from searching the php? I checked out the sleep command and it sounds like it stops the script from executing after so long, when I want it to keep executing. Is there any php command that re-executes the script after so much time?