1
$prodqty = mysql_query("SELECT quan FROM pro_list WHERE auto_id = $pid"); //get the current product quantity
if (mysql_num_rows($prodqty) != 0)
{
$row = mysql_fetch_array($prodqty);
$productqty = $row['quan'];
}
$nqty = $productqty-$q; //current product quantity minus order quantity to get new product quantity
if ($nqty >= 0)
{
$query2="UPDATE pro_list SET quan = $nqty WHERE auto_id = $pid"; //update the quantity in the product table
$result = mysql_query($query2);
if ($result)
echo "Successfully ";
else
echo "Unsuccesfully";
}
else
echo "Limit of quantity! .";
}
die('Thank You For Shopping With i-Supply System! your order has been sent to Admin.!');
}
庫存超出限制,但訂單仍然插入到數據庫中。訂單不應該插入表格順序,因爲它已經超出了產品的數量限制。客戶應該再次下單。爲什麼這會發生?庫存超限,仍插入訂單表
請顯示您的'$ q'。我們沒有看到你的'$ nqty = $ productqty- $ q'實際上做了什麼。 – Imran
$ nqty是訂單後產品的餘額,$ productqty是庫存的實際數量,$ q是客戶訂購時的數量。 @imran – ayeen