Originally posted by The Prohacker
Not really, you can have the page output an update during the mysql updates...
update progress bar 1%
update progressbar 3%
So... just echo out the update to browser and do the next db insert...
There is actually a problem with this solution ..
PHP by default buffers the output of the script until the buffer is full before sending it to the client, to achieve maximum network utilization. This buffering is also done at the Apache level, and the OS level. You can probably bypass all these buffers by calling flush(); ..
However, there are still other buffers you don't have control over, like buffering at a proxy server.
All-in-all, this is a nice method, but unreliable most of the time.
An alternative solution would be refershing the page for each chunk of the updates. Say you have 33,000 records to update, so what you do is make 1000 updates with every call, so you start by the first 1000, stop execution, return an HTML page that will display a progress bar and redirect to user to a URL that will cause the update of the next 1000 records, until you finish all the processing.
edit: check the man page for flush(), there is nice information about this issue. Also in the comments, somebody talks particularly about how he made a progress bar: