PHP脚本停止//循环遍历表

时间:2018-05-26 09:11:33

标签: php mysql while-loop timeout

我有一个非常简单的脚本循环遍历MySQL-Table(3500条记录)并将结果返回到HTML表中。

脚本突然(在500之后)没有错误地结束并且没有到达表的末尾。

任何想法都错了吗?非常感谢您的评论。

干杯

echo "<h1>This is PHP version " . phpversion() . "</h1>"; // returns 7.1.10
error_reporting(E_ALL);
ini_set('display_errors', 'on');

echo "<h3>Script Runtime: ". ini_get('max_execution_time') ." Sec.</h3>"; // returns 300
echo "<h3>Memory Limit: ". ini_get('memory_limit') ."</h3>"; // retuns 100M

$i = 0;
$sql = "SELECT * FROM tblClients ORDER BY lastname, firstname";
if (! $recClients = mysqli_query($GLOBALS['conn'], $sql)) {die("<p><b>SQL:</b><br>".$sql."</p>");}

    echo "<table>";
    echo "<tr>";
    echo   "<th>Nr.</th>";
    echo   "<th>Firstname</th>";
    echo   "<th>Lastname</th>";
    echo "</tr>";

    while ($rowClients = mysqli_fetch_assoc($recClients)) {

        echo "<tr>";
        echo   "<td>" . $i++ . "</td>";
        echo   "<td>" . $rowClients['firstname'] . "</td>";
        echo   "<td>" . $rowClients['lastname']  . "</td>";
        echo "</tr>";
    }
    echo "</table>";

0 个答案:

没有答案