【发布时间】:2015-08-22 12:07:32
【问题描述】:
我正在开发购物车应用程序。在此选定的产品 id 存储在会话变量中。如果用户想在购物车中添加其他产品,他将点击 Add More... 按钮。我想在同一会话变量中附加选定产品的 ID。
我的代码是:
shop_details_cart.php
$get_ids = $_GET['ids'];
$ids = json_decode($get_ids,true);
$id_string = implode(',', array_map(function ($entry) {
return $entry['id'];
}, $ids));
//$_SESSION['ids'];
//array_push($_SESSION['ids'],$id_string);
$_SESSION['ids']=$id_string;
$sql=mysql_query("select product_id,name,stock from $shop_loc where product_id IN($_SESSION[ids])");
【问题讨论】: