[PHP] help with session

Joined
Mar 19, 2006
Messages
2
Reaction score
0
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?
 
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?


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:
Code:
foreach($_SESSION['cart'] as $item)
  echo "Quantity: ".$item['quantity']."<p>Price:".$item['price'];

Alternatively, you can use print_r($_SESSION['cart']) to check what arrayvalues there are.

See also
PHP: Array Functions - Manual
 
Back