I m doing the following but it doesn t work. it only has 1 item in the array no matter how many i add
一个人能够告诉我,什么是错做的。
session_start();
$pid = mysql_real_escape_string(trim($_GET["pid"]));
$price = mysql_real_escape_string(trim($_GET["price"]));
$quantity = mysql_real_escape_string(trim($_GET["quantity"]));
if (!isset($_SESSION[ cart ])) {
$_SESSION[ cart ] = array();
$_SESSION[ cart ][ pid ] = $pid;
$_SESSION[ cart ][ total_price ] = $price;
$_SESSION[ cart ][ total_items ] = $quantity;
}else{
$_SESSION[ cart ][ pid ] = $pid;
$_SESSION[ total_price ] += $price;
$_SESSION[ total_items ] += $quantity;
}