Making a Please wait screen while looping database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Next_Gate
Forum Newbie
Posts: 15
Joined: Fri Dec 20, 2002 4:54 pm

Making a Please wait screen while looping database

Post 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!
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

Eh just a general question. Why do you need 5000 querys in one?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
dave420
Forum Contributor
Posts: 106
Joined: Tue Feb 17, 2004 8:03 am

Post 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)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

IE only requires 256 bytes of data before it'll start displaying..btw.
dave420
Forum Contributor
Posts: 106
Joined: Tue Feb 17, 2004 8:03 am

Post 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.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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
fangorn
Forum Commoner
Posts: 41
Joined: Fri May 21, 2004 9:04 am

Post 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.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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 ;)
Next_Gate
Forum Newbie
Posts: 15
Joined: Fri Dec 20, 2002 4:54 pm

Post 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!
Post Reply