尝试回显行。我没有得到任何错误,但如果我做第二部分它就有效。
<?php
$result = mysqli_query($db_connect, "SELECT * FROM items") or die ("Query is invalid." . mysqli_error());
if (!$row = mysqli_fetch_array($result)) {
echo "</table>".
"<font color='red'>".
"There are no items in the databse.".
"</font>";
} else {
while ($row = mysqli_fetch_array($result)) {
echo $row['Item_SKU'];
}
}
?>
这将打印数据库中的第一个项目,而不是所有项目
<?php
$result = mysqli_query($db_connect, "SELECT * FROM items") or die ("Query is invalid." . mysqli_error());
if (!$row = mysqli_fetch_array($result)) {
echo "</table>".
"<font color='red'>".
"There are no items in the databse.".
"</font>";
} else {
echo $row['Item_SKU'];
//while ($row = mysqli_fetch_array($result)) {
//
// echo $row['Item_SKU'];
//}
}
?>