|
Posted by pangea33 on 10/26/06 00:56
Laurent Haan wrote:
> As soon as you start the section in php where the loading
> screen is ment for, you send the html code to the client that invokes
> the javascript function that displays the loading screen. Finally, at
> the end of the php script, you send the invokation to the javascript
> function that hides the loading screen again.
This won't work because PHP is server-side and javascript is
client-side. NONE of the client-side js code will be executed on the
browser until all of the PHP code has executed. Basically, you won't
get a "loading" message until the job is already "loaded"
> This effect can't be realised by only using PHP...
That is not entirely true. You can make use of the php output buffer.
Keep in mind this is only a viable option when you're running multiple
PHP commands iteratively. For instance, say you're running a series of
PHP queries, such as inserting a master record which returns some
result details, then inserting records into multiple child tables, each
having some sort of result detail returned.
You can append the *result detail* stuff to the output buffer, while
echoing out the approximate change in percent completed. Once all the
SQL tasks are completed, you then dump out the buffer. This is
especially useful for transactional queries where everything rolls back
if something fails. The first link below has a pretty good example.
http://usphp.com/manual/en/function.ob-end-clean.php
http://us2.php.net/manual/en/function.ob-start.php
http://us2.php.net/manual/en/function.ob-get-contents.php
Navigation:
[Reply to this message]
|