MoFish Posted November 16, 2013 Share Posted November 16, 2013 (edited) Hi, I have a button which does 3 processes behind the scenes such as database imports and file extracts. I'm trying to write out a % status to indicate which part of the process is running. I have created an update_progress() function which passes in the percentage complete, but find that I only ever see 100% complete once the full script has run. if(isset($_POST['btnOneClick'])){ echo update_progress(0); mysql_dump($sql_url); echo update_progress(30); move_file_local($zip_url); echo update_progress(50); extract_zip(); echo update_progress(100); } In my update_progress function I have tried using flush() which I thought would have returned it to the screen instantly but have had no success. I also read that setting ini_set('output_buffering', 0); may have worked - but that also doesnt seem to work function update_progress($percent) { $bar = "<div class='progress-bar' role='progressbar' aria-valuenow='$percent' aria-valuemin='0' aria-valuemax='100' style='width: $percent%'> <span class='sr-only'>$percent% Complete</span> </div>"; return $bar; flush(); } Could anyone point me in the right direction? Cheers, MoFish Edited November 16, 2013 by MoFish Quote Link to comment Share on other sites More sharing options...
MDCode Posted November 16, 2013 Share Posted November 16, 2013 There are several issues that can cause flush() to fail as stated in the PHP docs. http://us1.php.net/manual/en/function.flush.php Quote Link to comment Share on other sites More sharing options...
MoFish Posted November 16, 2013 Author Share Posted November 16, 2013 Thanks - Ill have a read. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.