<div id="status">starting..</div>
for($i=1;$i<=100;$i++){
sleep(5);
?><script>
document.getElementById('status').innerHTML="<?php echo $i . '%'?>";
</script><?php
}
work with that, also your percentage calc should look like this (excuse the extra code which doesn't pertain):
if(($x=floor( ( $_i_ / $rows )*100)) > $percent){
$percent=$x;
//get estimated time remaining
if(time()>$startTime && $readStatus>0){
$delta=time()-$startTime;
$timeRemaining = round(($delta * (100-$readStatus)) / $readStatus);
$estTimeRemaining = time_english($timeRemaining) . " remaining";
}
//update status on page - you could write the javascript here
echo "<script>u($readStatus, '$estTimeRemaining');</script>";
//write update to .readstatus file
$fp[readstatus]=fopen($file.'.readstatus','w');
fwrite($fp[readstatus],"$readStatus percent of $rows running $startTime to ".time());
fclose($fp[readstatus]);
//update .status file also
$statusFileString=implode('',file($file.'.status'));
if(!preg_match('/<inprocess[^>]+>/i',$statusFileString,$sfs)){
//the status file should be present at this point
exit('Status file not present at time of start row processing, line '.__LINE__);
}
$currentInprocess=$sfs[0];
$newInprocess=xml_modify_tags($currentInprocess,'status',STAT_INPROCESS);
$newInprocess=xml_modify_tags($newInprocess,'posttime',time());
$newInprocess=xml_modify_tags($newInprocess,'currentrow',$i);
$statusFileString = str_replace($currentInprocess,$newInprocess,$statusFileString);
//write again
$fp[status]=fopen($file.'.status','w');
fwrite($fp[status],$statusFileString,strlen($statusFileString));
fclose($fp[status]);
}