当我将book_Status
从表格book
更新为AVAILABLE
时,我无法将reserve_Status
更改为RESERVED
。我的剧本出了什么问题?
reserve.php :
<?php
include 'dbconnect.php';
$query1 ="
SELECT b.book_Status, r.reserve_Status
FROM book b
JOIN reservations r
ON r.book_Accession = b.book_Accession
";
$result1 = mysql_query($query1) or die('SQL error');
$row1 = mysql_fetch_array($result1, MYSQL_ASSOC);
if ($row1['book_Status'] == 'Available')
{
$Reserved = "Reserved";
}
$query2 = "INSERT INTO reservations
WHERE reserve_Status = '$Reserved' ";
?>
答案 0 :(得分:0)
您需要update query
。并将该查询移到您的if
语句
if ($row1['book_Status'] == 'Available')
{
$Reserved = "Reserved";
$query2 = "UPDATE reservations SET reserve_status = 'reserved' WHERE book_Status='Available'";
}
答案 1 :(得分:0)
问题是您更改了变量$Reserved
的值,但未查询数据库以执行更新。