您的位置:首页 > 编程语言 > PHP开发

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

2012-12-23 22:17 113 查看
其实进度条的做法很简单的。网上的一大堆,自己写了一个,哈哈,感觉看起来很有感觉。

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;
}


效果截图: 100%的时候。



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: