I have some queries that update some statistics in a table I have. I need these queries to run only after 15 seconds have passed however. This way if the user leaves before the 15 seconds, the queries won't run. I've tried using Sleep, however it seems to just stop all the code all together for the allotted time. There must be a way to do this. :)

Hi Smudly,

As you have noticed, the PHP sleep function delays the script execution until the number of seconds is up. Consequently the user receives no feedback until after the sleep has finished and the script provides some output causing the page to look dead.

The less desirable (but easier) way to achieve your goal could be implemented using a HTML meta refresh to redirect the user after 15 seconds to another page that performs the queries.

The best way to achieve your goal would be using AJAX. You could set a timeout for 15 seconds which dynamically loads the results of the queries into the current page (the advantage being that the user doesn't have to load a whole new page as the previous method does).

Hope this heads you in the right direction,