PHP,Mysql网站不会加载

时间:2017-06-21 17:15:35

标签: php mysql sql for-loop while-loop

今天我从我的数据库中删除了make table,但不知何故,当我运行tis代码时,它会永远加载网站= \ $pismenka[0] to [25] are A, B, C .....

Databse 100%在我调用它时工作但是当我使用数组时它不是= \

Echo仅用于测试是否找到数据以及代码是否到达最终

问题短缺:网站永远不会加载所以没有错误= \只是whitesmoke屏幕

问题部分: while($db_data = mysqli_fetch_assoc(mysqli_query($connect_to_db, "SELECT * FROM anime WHERE a_name LIKE '$start1%'"))) { echo "aaaaaaaaaaaaaaa"; }

整个代码:

for ($i = 0; $i < count($pismenka); $i++) {
        echo "<div id='pismenko' class='text-center'>$pismenka[$i]</div>";
        $start1 = $pismenka[$i];
            echo "
            <table class=\"table table-striped table-hover\">
                <thead>
                    <tr>
                        <th style=\"width: 30%;\">Názov anime</th>
                        <th style=\"width: 10%;\">Rok vydania</th>
                        <th style=\"width: 10%;\">Preložené</th>
                        <th style=\"width: 10%;\">Hodnotenie</th>
                        <th style=\"width: 10%;\">Preklad</th>
                        <th style=\"width: 10%;\">Stav</th>
                    </tr>
                </thead>
                    <tbody>
            ";
            while($db_data = mysqli_fetch_assoc(mysqli_query($connect_to_db, "SELECT * FROM anime WHERE a_name LIKE '$start1%'"))) {
                echo "aaaaaaaaaaaaaaa";
            }
            echo "</tbody></table>";

    }

1 个答案:

答案 0 :(得分:2)

您有一个无限循环,因为您不断重新执行相同的查询并获得相同的结果。

执行查询一次

$result = mysqli_query($connect_to_db, "SELECT * FROM anime WHERE a_name LIKE '$start1%'");

然后遍历该查询的结果

while($db_data = mysqli_fetch_assoc($result)) {
    echo "aaaaaaaaaaaaaaa";
}