2 回答
TA贡献1872条经验 获得超3个赞
这样做是因为最后 2 个语句在循环中,如我所示将它们取出:
foreach($_SESSION["arrCart"] as $merch){
mysqli_query($con,"
INSERT INTO merch_history
(
nInvoiceID,
nProductsID,
nQty,
nPrice,
nImgID
) VALUES (
'".$invoiceID."',
'".$merch["id"]."',
'".$merch["currentQty"]."',
'".$merch["price"]."',
'".$value."'
)");
$sql = "UPDATE products SET nQty = nQty - '".$merch["currentQty"]."' WHERE id = '".$merch["id"]."'";
$sql = "UPDATE images SET nInvoiceID = '".$invoiceID."' WHERE nSessionID = '".$_SESSION['id']."'";
mysqli_query($con,$sql);
$sql = "SELECT
merch_history.id,
merch_history.nInvoiceID,
merch_history.nProductsID,
merch_history.nQty,
merch_history.nPrice,
images.id AS imgID,
images.strImage AS strImg
FROM merch_history
LEFT JOIN images ON images.id = merch_history.nImgID
";
}
$_SESSION['arrCart'] = array();
return $invoiceID;
- 2 回答
- 0 关注
- 123 浏览
添加回答
举报