<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>PHP Shopping Cart Demo · Cart</title> <link rel="stylesheet" href="css/styles.css" /> </head> <body> <div id="shoppingcart"> <h1>Your Shopping Cart</h1> <?php echo writeShoppingCart(); ?> </div> <div id="contents"> <h1>Please check quantities...</h1> <?php echo showCart(); ?> <p><a href="index.php">Back to bookshop...</a></p> </div>
} for ($i = 0; $i < $qty; $i++) { if ($newcart) { $newcart .= ',' . $prefix . $id; } else { $newcart = $prefix . $id; } } } } $_SESSION[$user . 'cart'] = $newcart; } else { if ($action == "reloadShoppingCart") { cleanCart(); $shoppingcart = showCart(); $preview = writeShoppingCart(); $cartpreview = writeCartPreview(); $result = array('cart' => $shoppingcart, 'preview' => $preview, 'cartpreview' => $cartpreview, 'session' => $cart); echo json_encode($result); } } } } function deleteItem($id, $cart) { $items = explode(',', $cart); $newcart = ''; foreach ($items as $item) { if ($id != $item) { if ($newcart != '') { $newcart .= ',' . $item;