I have an array of 'products' in my session, a product is an array of name, code and quantity, I want to change the quantity when I press a 'qty_up' button:
my PHP is this:
if ($_POST['qty_up']==''){
foreach ($_SESSION["products"] as $key => $val)
{
if ($val["product_code"] == $_POST['code']) {
$val["product_qty"] += 1;
}
}
}
This changes $val["product_qty"] but not the real value in the session
This is my 'products' array in the session:
array (size=1)
'products' =>
array (size=5)
213453 =>
array (size=5)
'product_qty' => string '1' (length=1)
'product_code' => string '213453' (length=6)
'product_name' => string 'Kingfisher' (length=10)
'product_price' => string '12.00' (length=5)
48754 =>
array (size=5)
'product_qty' => string '1' (length=1)
'product_code' => string '48754' (length=5)
'product_name' => string 'Minute maid' (length=11)
'product_price' => string '2.00' (length=4)
'3545231ES0' =>
array (size=5)
'product_qty' => string '1' (length=1)
'product_code' => string '3545231ES0' (length=10)
'product_name' => string 'Jagurt' (length=6)
'product_price' => string '1.00' (length=4)