源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

PHP 进度条函数的简单实例

  • 时间:2020-04-23 23:45 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:PHP 进度条函数的简单实例
[b]PHP 进度条函数的简单实例[/b] 其实进度条的做法很简单的。网上的一大堆,自己写了一个,哈哈,感觉看起来很有感觉。 实例代码:
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%的时候。 [img]http://files.jb51.net/file_images/article/201709/2017919161540045.png?201781916166[/img] [img]http://files.jb51.net/file_images/article/201709/2017919161614865.png?2017819161634[/img] 如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部