<?php
$conn = mysqli_connect ("localhost", "B00657633", "Jpr3EjPw")
or die ("could not connect: " . mysqli_error($conn));
print "successful connection<br>";
mysqli_select_db($conn, 'B00657633') or die ('db will not open');
header('Location: sql5_2.php');
$query = "UPDATE patient3 SET AGE=68 WHERE POST_CODE='bt667ed'";
$result = mysqli_query($conn, $query) or die ("Query is invalid");
$rownum = mysqli_num_rows($conn)
$col = mysqli_num_fields($conn);
echo "<table border='2'><tr><th>POST_CODE</th>";
for($i=0; $i<$rownum; $i++){
$rows = mysqli_fetch_row($result);
echo "<tr>";
for($j=0; $j<$col; $j++){
echo "<td>" . $rows[$j] . "</td>";
}
echo "</tr>";
}
echo "</table>";
$rownum = mysqli_affected_rows($conn);
echo $rownum . " Records have been updated.";
mysqli_close($conn);
?>
這是我的網頁的第一部分,第二部分是如下:使用PHP來更新MySQL的記錄
<?php
$conn = mysqli_connect ("localhost", "B00657633", "Jpr3EjPw")
or die ("could not connect: " . mysqli_error($conn));
print "successful connection<br>";
mysqli_select_db($conn, 'B00657633') or die ('db will not open');
$query="SELECT * FROM patient3";
$result = mysqli_query($conn, $query) or die ("Query is invalid");
$num = mysqli_num_rows ($result);
$col = mysqli_num_fields ($result);
echo "<table border='2'><tr><th>PATNUM</th><th>PAT_FORENAME</th><th>PAT_SURNAME</th><th>STREET_ADDRESS</th><th>TOWN</th><th>POST_CODE</th><th>AGE</th>";
for($j=0; $j<$num; $j++){
$rows = mysqli_fetch_row($result);
echo "<tr>";
for($i=0; $i<$col; $i++){
echo "<td>" . $rows[$i] . "</td>";
}
echo "</tr>";
}
echo "</table>";
echo " Records have been updated.";
mysqli_close($conn);
?>
無論我嘗試它沒有讓我在更新的任何信息,我SQL。真的不知道我哪裏出錯了,請幫助我。第二部分是顯示我的表格。連接到服務器是好的,但是一旦我點擊刷新,表格中沒有任何變化
用戶是否有權更新表格? – ashin999
你假設你的查詢正在工作。你有沒有啓用錯誤報告? –
你也要去不同的頁面?在運行任何查詢之前 – Mihai