php 프로그레스바 > php

본문 바로가기
사이트 내 전체검색

php

php 프로그레스바

페이지 정보

작성자 서방님 댓글 0건 조회 161회 작성일 17-08-26 08:11

본문

<!DOCTYPE html>
<html>
<head>
  <title>Progress Bar</title>
</head>
<body>
<!-- Progress bar holder -->
<div id="progress" style="width:500px;border:1px solid #ccc;"></div>
<!-- Progress information -->
<div id="information" style="width"></div>
<?php
/**
 * The long running PHP process should be placed here before we close
 * the <body> and <html> tags.
 *
 * In the following demo, the long running process is simulated using
 * basic loop with 1 second delay for each iteration.
 */

/**
 * Set the maximum execution time to 5 minutes (300 seconds).
 * We can flexibly adjust it to fit our need. If we need unlimited time,
 * just set it to 0 but be carefull there will be performance impact.
 */
set_time_limit(300);

// Total processes
$total = 10;

// Loop through process
for($i=1; $i<=$total; $i++){
  // Calculate the percentation
  $percent = intval($i/$total * 100)."%";

  // Javascript for updating the progress bar and information
  echo '<script language="javascript">
  document.getElementById("progress").innerHTML="<div style=\"width:'.$percent.';background-color:#ddd;\">&nbsp;</div>";
  document.getElementById("information").innerHTML="'.$i.' row(s) processed.";
  </script>';

  // This is for the buffer achieve the minimum size in order to flush data
  echo str_repeat(' ',1024*64);

  // Send output to browser immediately
  flush();

  // Sleep one second so we can see the delay
  sleep(1);
}

// Tell user that the process is completed
echo '<script language="javascript">document.getElementById("information").innerHTML="Process completed"</script>';
?>
</body>
</html>


http://stuff.w3shaman.com/php-ajax-progress-bar/

댓글목록

등록된 댓글이 없습니다.

Total 612건 11 페이지
게시물 검색

회원로그인

접속자집계

오늘
14
어제
90
최대
1,347
전체
154,301
Latest Crypto Fear & Greed Index

그누보드5
Copyright © 서방님.kr All rights reserved.