PHP在公共函数中超时

PHP在公共函数中超时,php,html,function,Php,Html,Function,我正在从batabase中提取一个大型sql查询,50000条记录。它大约在5秒钟内完成,但在拉取之后,我通过一个函数运行它来创建一个html表,由于某种原因,它一直超时。我可以将查询限制为您应该做的事情,以避免此类事情: 使用ini_集、ini_集“内存限制”和“512M”增加PHP内存余量; 所以你的代码应该是: public function report_table($data, $header_spacing, $column) { ini_set('memory_limit','51

我正在从batabase中提取一个大型sql查询,50000条记录。它大约在5秒钟内完成,但在拉取之后,我通过一个函数运行它来创建一个html表,由于某种原因,它一直超时。我可以将查询限制为您应该做的事情,以避免此类事情:

使用ini_集、ini_集“内存限制”和“512M”增加PHP内存余量; 所以你的代码应该是:

public function report_table($data, $header_spacing, $column)
{
ini_set('memory_limit','512M');
//then your loop
}
添加分页无论是php还是jquery,我都有一个类似的要求,显示超过65K条记录,使用下面的jquery进行分页,效果非常好。选中此项:
您正在使用分页吗?为什么不使用它一次显示几百条记录呢?为什么不将SQL查询限制在更少的记录上,比如说,制作表。。500行并进行分页?我不认为在html表格中有很多行是好的做法。浏览器可能占用太多内存。顺便说一句。。你的超时。。。检查你的php.ini,我相信有60秒的限制,所以增加它。请分享生成html表的代码。也许一双额外的眼睛可以捕捉到一些你错过的优化。但正如其他人所说,分页将是一种更强大的方法solution@MartinJoneš我想他的主要问题是当浏览器试图呈现如此巨大的数据量时,浏览器的问题。所以,我会尝试一个分页系统:这个系统修复了它。干得好
public function report_table($data, $header_spacing, $column)
{


    $html = "<div class='accordion_div'>";

    foreach($data as $d_row){

        $title = $d_row[0][$column];
        $html .= $this->accorion_button($title);
        $html .= "<div class='panel'><table border='0' style='$align; width: 980px;'>";
        foreach($d_row as $d1){


            $html .= "<tr>";
            $x=0;
            $y=$x+1;
            $html .=    "<td style='width: $header_spacing[$x];' scope='col' >&nbsp;</td>";
            foreach($d1 as $d){

                    $html .=    "<td style='width: $header_spacing[$y];' scope='col' >$d</td>";

                $x++;
                $y++;
            }

            $html .= "</tr>";
        }

            $html .= "</table>";
        $html .= "</div>";

    }



    return $html;
}
public function report_table($data, $header_spacing, $column)
{
ini_set('memory_limit','512M');
//then your loop
}