0
我在更新IF語句中的多個變量時遇到了一些麻煩,並且不確定哪裏出錯。在IF語句中更新多個變量
這裏是我的代碼:
$id = $_POST['retrive_quantity'];
$n_quantity = $_POST['n_quantity'];
$result2 = mysql_query ("SELECT * FROM stock_control WHERE id = '$id' ");
while ($row1 = mysql_fetch_array($result2))
{
$quantity=$row1['quantity'];
$threshold=$row1['threshold'];
$emailSent=$row1['email_sent'];
$orders_status=$row1['orders_status'];
$orders=$row1['orders'];
}
if ($quantity + $n_quantity > $threshold && $emailSent == 2) {
$update=0 && $orders_status=0 && $orders=0;
} else {
$update=2 && $orders_status=1 && $orders=$orders;
}
mysql_query("UPDATE stock_control SET quantity=quantity + '$n_quantity',
email_sent = '$update', orders_status = '$orders_status', orders = '$orders'
WHERE id = '$id' ");
if語句工作的第一線,並且還與變量的只有一個,但沒有多。
使用前的變量爲什麼你們不寫這樣的事情? $ update = $ orders_status = $ orders = 0; – Blauharley
我也建議不要使用'mysql_'函數,因爲這些函數在較新版本的PHP中已被棄用。 –