简体   繁体   中英

PHP | MySQLi : How to echo statement while WHILE-LOOP is running

Maybe a stupid question,

I have a script that cycles through 1000s of rows in a WHILE loop. In each pass there is an MySQLi update query being triggered, so the script takes a long time to run (10+ mins). (this is on localhost)

In the loop I have an ECHO but the values don't show up until after the entire script is done running. I need the echos to print on the screen while its running.

Is there a way to force it to echo a value on each pass? and not do it all at the end.

Taken from this

You can use output buffering like this:

ob_start();

echo('doing something...');

// send to browser
ob_flush();

// ... do long running stuff
echo('still going...');

ob_flush();

echo('done.');
ob_end_flush();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM