我已經通過此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))
,應該使用該
這樣做。謝謝。我會接受這個答案 – rpivovar