MySQL的记录HTML表中不显示

问题描述:

我已经通过此YouTube教程的工作我的方式:https://www.youtube.com/watch?v=1YbbUS_SxSk&t=609sMySQL的记录HTML表中不显示

..和出于某种原因,从我的MySQL表我的数据不打印在所有的表中,虽然有似乎是HTML表格中正确的行数。连接到MySQL并连接到适当的表似乎工作正常 - 记录只是不打印在表中。

> <html> 
    <head> 
     <title>Delete Records</title> 
    </head> 
    <body> 
     <table border=1 cellpadding=1 cellspacing=1> 
      <tr> 
       <th>Image</th> 
       <th>Delete</th> 
      </tr> 
      <?php 
       //connect with mysql 
       $con = mysqli_connect('localhost', 'root', ''); 
       if (!$con){ 
        echo"Connection not established"; 
       } 
       //select database 
       mysqli_select_db($con, 'photos'); 

       //select query 
       $sql = "SELECT * FROM images"; 
       if(!$sql){ 
        echo"Table not selected"; 
       } 

       //execute the query 
       $records = mysqli_query($con, $sql); 

       while (mysqli_fetch_array($records)){ 
        echo "<tr>"; 
        echo "<td>".$row['image']."</td>"; 
        echo "<td><a href=delete.php?id=".$row['ID'].">Delete</a></td>"; 
        echo "</tr>"; 
       } 
      ?> 
     </table> 
    </body> 
</html> 

这是表最终看起来像: HTML Table

在表中没有数据!

while ($row = mysqli_fetch_array($records))

,应该使用该

改变这一行

  while (mysqli_fetch_array($records)){ 

  while ($row = mysqli_fetch_array($records)){ 
+0

这样做。谢谢。我会接受这个答案 – rpivovar

简单的错误允许*流动的代码