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

Edited by MoFish
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.