這就是我想要做的。 如果一個人買一盞燈,product_quantity
將上浮了1 另一個人購買同樣的產品,但「product_quantity」是3 所以,如果總額高達其4使用sql添加一個數字
這是我的代碼:
// build SQL statement to select how many quantities of that product.
$query = "select product_quantity from table where order_item_name = '$ordername' and order_id='$orderid'";
// execute SQL statement
$result = mysqli_query($link, $query) or die(mysqli_error($link));
// shows how many quantity of that product
while($row= mysqli-fetch_assoc($result)){
$lol = $row['product_quantity']
}
但是,如何使用SQL將此數字添加到表中的現有數字? 例如,在該表中,有一個名爲total_order
場:10 我希望將新訂單增加:數量1和3到現有total_order
:10同樣的產品,使其14
您必須添加更新查詢以更新數據庫中的數量。 – admoghal
但如果我更新1 total_order,將total_order更新爲'1'而不是'11'? –
嘗試''更新表設置product_quantity = product_quantity + 1其中order_item_name ='$ ordername'和order_id ='$ orderid'「' – GBD