MoFish Posted November 16, 2013 Share Posted November 16, 2013 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 Link to comment https://forums.phpfreaks.com/topic/283967-return-value-to-screen-during-process/ 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 Link to comment https://forums.phpfreaks.com/topic/283967-return-value-to-screen-during-process/#findComment-1458570 Share on other sites More sharing options...
MoFish Posted November 16, 2013 Author Share Posted November 16, 2013 Thanks - Ill have a read. Link to comment https://forums.phpfreaks.com/topic/283967-return-value-to-screen-during-process/#findComment-1458572 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.