tags:

views:

46

answers:

2

Running a PHP script that is doing a huge mysql query plus some crunching on the results. Because of this the script takes a long time to execute and may appear to be not working to the user.

Is there a way to provide feedback to the user that the script is running? Perhaps way to print to the browser with each loop - indicating what record it's on... kind of a "live output buffer" or something?

+4  A: 

Try using flush(). http://us3.php.net/flush

You could also have a main page, that uses Javascript/jQuery to request the work page. Then, Javascript could show a nice little loader box telling you the the page is still doing stuff!

Chacha102
A: 

Do the request in an iframe. That way the user sees a page while the results are still being loaded in the frame. Ajax would work as well.

SpliFF
Please use ajax not an iframe :)
Joe Philllips
that's fine if you want to force your users to have JS enabled. That isn't always a good idea. Also ajax is more difficult to implement.
SpliFF