1

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.

vitalyp
  • 671
  • 4
  • 12
  • 23
  • Learn about PHP buffers and flushing the buffer - this should help http://stackoverflow.com/questions/4191385/php-buffer-ob-flush-vs-flush – Trent Dec 16 '15 at 00:48
  • i've tried searching for it, but had no luck. OB_START seems to be the right thing. Thank you. I've tried it but doesn't seem to work for me. – vitalyp Dec 16 '15 at 01:01
  • So I put ob_start() before WHILE-LOOP. Inside the loop i have an ECHO and after echo i have ob_clean() (tried ob_flush too). Anyway. not working, but i least i know what to research now. I will keep trying. THANKS AGAIN – vitalyp Dec 16 '15 at 01:03

1 Answers1

0

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();
Community
  • 1
  • 1
davejal
  • 6,009
  • 10
  • 39
  • 82