A simple example of PHP progress bar function

小云云
Release: 2023-03-19 12:36:02
Original
1433 people have browsed it

This article mainly introduces relevant information about simple examples of PHP progress bar function. I hope this article can help everyone. Friends in need can refer to it. I hope it can help everyone.

Simple example of PHP progress bar function

In fact, the progress bar is very simple. There are a lot of them on the Internet, so I wrote one myself, haha, I think it looks very interesting.

Instance code:


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

Effect screenshot: 100% of the time.

Related recommendations:

jquery web page loading progress bar implementation method

How to display the HTML5 Ajax file upload progress bar

Ajax method to implement the loading progress bar

The above is the detailed content of A simple example of PHP progress bar function. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template