PHP 进度条函数的简单实例

yipeiwu_com6年前PHP代码库

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

效果截图: 100%的时候。

如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

相关文章

PHP代码网站如何防范SQL注入漏洞攻击建议分享

黑客通过SQL注入攻击可以拿到网站数据库的访问权限,之后他们就可以拿到网站数据库中所有的数据,恶意的黑客可以通过SQL注入功能篡改数据库中的数据甚至会把数据库中的数据毁坏掉。做为网络开发...

php ios推送(代码)

复制代码 代码如下:<?php//php需要开启ssl(OpenSSL)支持$apnsCert    = "ck.pem";//连接到APNS时的证书...

php access 数据连接与读取保存编辑数据的实现代码

复制代码 代码如下: $conn = new com("ADODB.Connection"); $connstr = "DRIVER={Microsoft Access Driver (...

解决file_get_contents无法请求https连接的方法

错误: Warning: fopen() [function.fopen]: Unable to find the wrapper "https" - did you forget to...

php 随机数的产生、页面跳转、件读写、文件重命名、switch语句

复制代码 代码如下:<?php num = rand(1,5); witch($num){ case 1: $fp1=fopen("f1.dat",'r'); $oname = f...