I am in need of a progress bar.... one that I can control the % done as code processes.
I need to send out a large batch of emails and as they are sent, I need to keep a running on screen tally.
I've tried a couple I have found all with the same results. I thought it might have been a more complex coding issue and couldn't find a solution.
I then stumbled on a very basic script that did the same thing. Now I KNOW it's not a coding issue.
<?php
echo '<div id="progress" style="width: 100px;border: 1px solid black"><div id="progress_bar" style="height: 24px; width: 1px;background: blue;"></div></div>';
ob_flush(); flush(); sleep(5); // <- forces output to be sent to browser
// tell the user we're 10% done:
echo '<script>document.getElementById("progress_bar").style.width = \'10px\'; </script>';
ob_flush(); flush(); sleep(5);
// tell the user we're 50% done:
echo '<script>document.getElementById("progress_bar").style.width = \'50px\'; </script>';
ob_flush(); flush(); sleep(5);
// tell the user we're 80% done:
echo '<script>document.getElementById("progress_bar").style.width = \'80px\'; </script>';
ob_flush(); flush(); sleep(5);
// tell the user we're 100% done:
echo '<script>document.getElementById("progress_bar").style.width = \'100px\';</script>';
ob_flush(); flush(); sleep(5);
?>
What is happening, is the page "runs"... I watch the Firefox "loading" prompts, but the bar does not appear until the END of the entire page loading... aka... 100%. Then the full bar is shown.
It appears to be something maybe with the buffering but as a new PHP programmer have no idea what to do.
I thought about using a Javascript bar and calling it from PHP, but not sure if that is the best idea either.
Suggestions?