Page 1 of 1

Making a Please wait screen while looping database

Posted: Wed May 26, 2004 8:06 pm
by Next_Gate
Well heres my doubt.. i have to make a HUGE query to the database.. im talking about 5000+ querys in one loop... so i was wondering how do i make a waiting screen while the results are shown..

i usually get all the htm ito a variable and then at the end i print it out..

i did something with javascript opening another window and shile looping i send informtion to a textbox in the new opened window.. but my prolem is that the echo that sends the info to the other window doesnt do it continusly.. for example.

when i enter page 1 (the one that makes the querys), i make an ECHO and open the new window but that doesnt occur inmeaditly it happens just 2 or 3 seconds after entering the page.. and then while looping i make another echo everytime it loops ,. but the "counter" in the other page doesnt refresh inmedialty.. its smething like php waits n seconds or something to return data to the browser.

Any help here?.. how can i tell PHP that i want the data to be echo every tiem it llops..

Thnaks in advance.. sorry for my english. if something here that you could understand please ask me..

Thanks again!

Posted: Wed May 26, 2004 8:26 pm
by Joe
Eh just a general question. Why do you need 5000 querys in one?

Posted: Wed May 26, 2004 8:30 pm
by feyd
depending on your server, you can use [php_man]flush[/php_man]() at the end of each loop.. you'll need a bit of design work, so browsers can show the data correctly with each pass.

Posted: Thu May 27, 2004 3:23 am
by dave420
Microsoft Explorer needs a bit of data outputted to it before it will render an incomplete page. A good way to do that is to put in a large amount of garbage text inside HTML comments. That will cause IE to render anything that follows. Then, as feyd says, use flush() to output your update messages. Also remember, you can output <script>...</script> blocks between flushes, and these scripts can update DHTML elements in your page as they go. This lets you have a visually very nice page showing a constantly-updated display. (Just make sure to have the entire script block outputted between flushes, not just adding to an existing block, otherwise the script isn't executed on-the-fly, but when you close the script tag)

Posted: Thu May 27, 2004 3:38 am
by feyd
IE only requires 256 bytes of data before it'll start displaying..btw.

Posted: Thu May 27, 2004 5:26 am
by dave420
feyd - thanks for finding out the amount :) So, as long as you output 256 bytes before your flush-o-rama, you'll be fine.

Posted: Thu May 27, 2004 6:20 am
by JayBird
Read my posts in this thread for a nice way of doing things

viewtopic.php?t=12436&start=0&postdays= ... ight=sleep

Mark

Posted: Thu May 27, 2004 10:58 am
by fangorn
Using the DIV tag and the style visibility and inline is the way to go - like Bech100's link says. I also use the innerHTML tag for IE to change the text while looping. I use this extensively and it makes the page and the loading quite attractive. But if you're doing 5000 actual queries, you should revamp your script. Hopefully you mean 5000 records - this isn't much though.

Posted: Thu May 27, 2004 10:59 am
by JayBird
fangorn wrote:Using the DIV tag and the style visibility and inline is the way to go. Use the innerHTML tag for IE if you want to change the text while looping.
Exactly where my link take him to ;)

Posted: Thu May 27, 2004 5:36 pm
by Next_Gate
thanks for all your replies.. i did it in these way..

I was printing ALL the data after it was collected.. but i did a work around for this and entering the function i make an ECHO for a javascript that opens a new window using the FLUSH() function then, inside the loop of the query i use another echo and flush for sending the progress in percentage to the new window opened in a form. thants the way i did it..

Thanks!