1. First of all open the file progressbar.php
2. Writte the following peace of htm,php and javascript code in progressbar.php file.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<title>Progress Bar Script</title>
</head>
<body>
<!-- Progress bar holding -->
<div id="progres" style="width:500px;border:1px solid #ccc;"></div>
<!-- Progress information detail -->
<div id="info" style="width"></div>
<?php
ob_end_flush();
// No. of processes
$total = 10;
// Implement Loop through process
for($i=1; $i<=$total; $i++){
// Calculate the percentation
$percent = intval($i/$total * 100);
// Use Javascript for update the progress bar and information
echo '<script language="javascript">
document.getElementById("progres").innerHTML="<div style=\"width:'.$percent."%".';background-color:#ddd;\"> </div>";
document.getElementById("info").innerHTML="'.$i.' row(s) processed.";
</script>';
// Output send to browswer
flush();
// Sleep one second
sleep(1);
}
// To show the process is completed
echo '<script language="javascript">document.getElementById("info").innerHTML="Process completed"</script>';
?>
</body>
</html>
Blogger Comment
Facebook Comment