Jump to content

Return Value To Screen During Process


MoFish

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.