if (!empty($_GET['action'])) {
$j = $_GET['id_'];
switch($_GET['action']) {
case "add":
$query = "select * from ogl where id = $j";
$result = mysqli_query($conn, $query);
$row = mysqli_fetch_assoc($result);
$array = array($row["id"]=>array('seller'=>$row["seller"],
'name'=>$row["name"], 'cpu'=>$row["CPU"], 'size'=>$row["size"],
'price'=>$row["price"], 'img'=>$row["img"]));
if (empty($_SESSION["cart_item"])) {
$_SESSION["cart_item"] = $array;
} else {
$_SESSION["cart_item"] = array_merge($_SESSION["cart_item"], $array);
}
break;
}
}
問題是,它只添加一個項目,通過替換以前添加的項目。每個項目的ID都是通過它們的按鈕 - GET方法發送的。問題是什麼?謝謝。PHP購物車,添加多個項目
https://stackoverflow.com/help/how-to-ask - 閱讀本文,然後您可以編輯此問題。我不確定你想要完成什麼,也不應該爲了幫助你解決問題而弄清楚。給你的問題多一點背景。如果你願意,我會收回我的投票;) – Jase