-2
有以下PHP:獲取與mysqli的數據庫條目
<?php
session_start();
$conn = mysqli_connect("localhost", "test", "", "test");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql = "SELECT status FROM updates";
if ($result = mysqli_query($conn, $sql)) {
while ($row = mysqli_fetch_row($result)) {
echo '<div class="statusRow">' . "Status: " . $row['status'] . '</div>';
}
mysqli_free_result($result);
}
mysqli_close($conn);
?>
以上沒有返回所期望的「地位」輸入,只是空白。不知道我在這裏錯過了什麼?
基本的錯誤檢查和顯示。 – rtfm
@KevinP輸出是「狀態:」 –
將$ row ['status']更改爲$ row [0] –