阅读背景:

PHP 进度条函数,很不错的!自己写的

来源:互联网 

其实进度条的做法很简单的。网上的一大堆,自己写了一个,哈哈,感觉看起来很有感觉。

function ShowPercent($now,$total)
{
  $percent = sprintf('%.0f',$now*100/$total);
  $html = '<table width="60%" style="border-collapse:separate" height="10" border="0" cellpadding="0" cellspacing="2" bgcolor="#fff"><tr>';
  $count=0;
  $pertr = 30;
  while($count < $total)
  {
    $bgcolor = $count < $now ? 'green':'#EEEEEE';
    $html .= '<td bgcolor="'.$bgcolor.'"> </td>';
    $count++;
    if($count%$pertr == 0) $html .= '</tr><tr>';
  }
  $bgcolor2 = $now == $total ? ' style="font-weight:bold;color:green;"':'';
  $html .= '<td'.$bgcolor2.' colspan="'.($count%$pertr).'">'.$percent.'%</td></tr></table>';
  return $html;
}f



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: