Ok, I'm trying to write a script that runs every 10 seconds. This script is used for checking who's online and relaying messages and stuff like that.
Most of the time, it's not going to do anything except check the database for changes but if there is a change then it's going to do a bunch of things depending on the necessary task for that particular user.
Anyway, the obvious way to do this is to have a hidden frame that refreshes every 10 seconds. The problem with this is that the refresh makes a clicking sound on some browsers and on others (depending on the setting) it briefly shows a progress bar on the bottom during the refresh.
That is annoying and I'm looking for an alternative.
The first alternative is to have a swf file run in the background and run a my PHP script every 10 seconds. I'm just not sure if the browsers will still do their update/clicking thing if the PHP file is loaded through FLASH
The next option is to have a hidden PHP file that's set up like this:
I'll set the timeout for 5 minutes.
there will be a loop in the script.
Within that loop will be all the scripting that I need to do every 10 seconds and at the end there will be a sleep(10) function.
Within loop there will also be a counter.
When the counter gets close to the end of the page cycle(35), it will refresh the page.
I know that I'll still have the refreshing problems but once every five minutes is much better than then once every ten seconds. How's that solution? Anyone have a better idea or see any problems with it?
Thanks for you time!!