用于大型数据集的php脚本挂起

用于大型数据集的php脚本挂起,php,html,mysqli,phpmyadmin,Php,Html,Mysqli,Phpmyadmin,我正在建立一个网站,它从另一个网站上抓取数据,存储在数据库中,并以表格的形式显示。只要行数减少(大约100行),一切都可以正常工作,但当数据集增加时,比如说300行或更多,数据就会存储在数据库(phpmyadmin)中,但屏幕上没有显示任何内容,站点就会继续加载。下面是我正在运行的php脚本的一部分: <?php // configuration require("../includes/helpers.php"); // initializing current p

我正在建立一个网站,它从另一个网站上抓取数据,存储在数据库中,并以表格的形式显示。只要行数减少(大约100行),一切都可以正常工作,但当数据集增加时,比如说300行或更多,数据就会存储在数据库(phpmyadmin)中,但屏幕上没有显示任何内容,站点就会继续加载。下面是我正在运行的php脚本的一部分:

<?php

// configuration
require("../includes/helpers.php"); 

        // initializing current page and number of pages
        $page = 0;
        $pages = 1;

        // scrape data from each page
        while($pages--)
        {
            // next page
            $page++;

            // scrape data from shiksha.com
            $string = @file_get_contents("http://www.shiksha.com/b-tech/colleges/b-tech-colleges-".urlencode($_POST["city"])."-{$page}");

            if($string === false)
                apologize("Please enter a valid city name");

            if($page === 1)
            {
                // counting total number of pages
                preg_match_all('/class=" linkpagination">/',$string,$result);
                $pages = sizeof($result[0]);
            }

            // passing the string for scraping data  and storing in database
            get_college_info($string,$page);

            // delay for 2s
            sleep(2);
        } 


        // querying the infrastructure table for facilities of all colleges
        $infra = query("SELECT college_id,facilities FROM infrastructure ");

        // preparing query and selecting data from table college_info
        $result = query("SELECT * FROM college_info");

        // render(output) results
        render("result.php",["title" => "result","infra" => $infra,"result" => $result]);
    }
}?>

有趣的是,如果我已经将数据存储在我的数据库中,并且我只是检索并打印它,那么一切都可以正常工作,所有的数据,不管它有多大,都可以打印出来。我不知道是什么问题。
PS:我已经尝试设置时间限制()。

您正在创建一个无限循环。因此,要解决此问题,请将
while
循环的标准更改为以下内容

while($page<$pages)
{
    //your same code here
}

虽然($page)我不认为这是问题所在,但无论如何我试过了,它仍然不起作用。@user3299379