> I am looping through a few thousand records and would like to display
> the results every loop. Eg:
>
> while($row = mysql_fetch_object($sql)):
> echo "Hi $row->name<br>";
> flush();
> endwhile;
>
> A simple example - but you see what I am trying to achieve. Perhaps a
> more realistic example is displaying the results of a mail program as
> it fires off mail to hundreds of members in a database.
>
> Will this slow down the execution of the script at all - or much?

Probably not.

All it should do, I would think, would maybe send out more and smaller
TCP/IP packets than normal...

If you're really concerned, why not do:

$rowcount = 0;
while (...){
    $rowcount++;
    if ($rowcount % 50 == 0){
        flush();
    }
}

That will flush every 50 records, which is about a screen-ful, and have
virtually no overhead.

You should play with it all three ways to see if it makes any difference.

Probably you won't be able to tell.

In fact, if you have these rows in a table, your output to the browser is
irrelevant.  The browser waits for the closing TABLE tag, and then decides
how to layout the table, and then displays it, and all the flushing in the
world won't matter.

flush() is more useful if you are sending very little (or no) data with long
processing involved or in between each datum.  I've only found flush()
useful in the real world when I'm doing something to every record with
nothing to really output, and so I output a "." so they know I'm not dead.

--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to