need help with php
$pid = $_GET['pid'];
in between i have the mysql query and $result and fetching
$_SESSION['cart']['$pid'] = array('quantity' == 1, 'price' == $price );
Next, how do i display the session['cart'] and ['pid] values?
Printable View
need help with php
$pid = $_GET['pid'];
in between i have the mysql query and $result and fetching
$_SESSION['cart']['$pid'] = array('quantity' == 1, 'price' == $price );
Next, how do i display the session['cart'] and ['pid] values?
erm like
$_SESSION['cart']['$pid']['quantity']
$_SESSION['cart']['$pid']['price']
?
PLEASE don't tell me you're making a webshop...
Kids these days...
1. its array('quantity' => 1, 'price' => $price), == is not an assignment operator but a comparison operator so putting it there makes no sense at all.
2. To display a list of products in the $_SESSION['cart'] its easiest to use a while or foreach loop:
Alternatively, you can use print_r($_SESSION['cart']) to check what arrayvalues there are.Code:foreach($_SESSION['cart'] as $item)
echo "Quantity: ".$item['quantity']."<p>Price:".$item['price'];
See also
PHP: Array Functions - Manual