mysqli ignoring the first row in a table

前端 未结 4 1637
长发绾君心
长发绾君心 2021-01-25 18:14

Here is the code I\'m using to pull the data from the table:

require_once \'connect.php\';
$sql = "SELECT * FROM `db-news`";
$result = $mysqli->query         


        
4条回答
  •  渐次进展
    2021-01-25 18:51

    The problem is the first row of the following excerpt:

    $row = mysqli_fetch_assoc($result);
    while ($row = $result->fetch_assoc()) {
    

    The mysqli_fetch_assoc already gets the first row (and thus in the while loop you are already 1 step further). You should either put that line instead of the $reslut->fetch_assoc part into the while statement or delete it. That should solve the problem.

提交回复
热议问题