如何在仍然运行PHP循环的同时加载页面?

时间:2017-10-01 01:13:57

标签: php while-loop web loading

在我的网站上,我有这个PHP代码:

 while(1) {
      sleep(1);
if ($result->num_rows == 0) {
  $players = "0 Players";
} else if ($result->num_rows == 1) {
  $players = "1 Players";
} else if ($result->num_rows == 2) {
  $players = "2 Players";  
} else if ($result->num_rows == 3) {
  $players = "3 Players";  
} else if ($result->num_rows == 4) {
  $players = "4 Players";  
} else if ($result->num_rows == 5) {
  $players = "5 Players";  
} else if ($result->num_rows == 6) {
  $players = "6 Players";  
} else if ($result->num_rows == 7) {
  $players = "7 Players"; 
} else if ($result->num_rows == 8) {
  $players = "8 Players";  
} else if ($result->num_rows == 9) {
  $players = "9 Players";  
}
   }

问题是页面无法加载。我的猜测是PHP循环需要在页面加载之前结束。但是,这需要在页面加载完毕时运行。

有什么想法吗?提前谢谢。

并且如果它有助于网站托管。主持人并不慢。

0 个答案:

没有答案