$_SESSION['total']['count'] = 0;
$_SESSION['total']['summ'] = 0;
$id = $_POST['id'];
if($_SESSION['cart']) {
if($_SESSION['cart'][$id]) {
$_SESSION['cart'][$id]++;
}
else {
$_SESSION['cart'][$id] = 1;
}
foreach($_SESSION['cart'] as $key => $val) {
$_SESSION['incart'][$key] = pageData("SELECT title, price, img FROM records WHERE id=".$key);
$_SESSION['incart'][$key]['count'] = $val;
$sum = $_SESSION['incart'][$key]['price'] + $_SESSION['incart'][$key]['count'];
}
print_r($_SESSION['incart']);
}
else {
$_SESSION['cart'][$id] = 1;
}
$_SESSION['total']['count'] = 0;
$_SESSION['total']['summ'] = 0;
$id = $_POST['id'];
if($_SESSION['cart']) {
if($_SESSION['cart'][$id]) {
$_SESSION['cart'][$id]++;
}
else {
$_SESSION['cart'][$id] = 1;
}
foreach($_SESSION['cart'] as $key => $val) {
$_SESSION['incart'][$key] = pageData("SELECT title, price, img FROM records WHERE id=".$key);
$_SESSION['incart'][$key]['count'] = $val;
$sum = $_SESSION['incart'][$key]['price'] * $_SESSION['incart'][$key]['count'];
$_SESSION['total']['count'] += $_SESSION['incart'][$key]['count'];
$_SESSION['total']['summ'] += $sum;
}
print_r($_SESSION['incart']);
print_r($_SESSION['total']);
}
else {
$_SESSION['cart'][$id] = 1;
}