HI all can someone help me to change this code so that it adds another key and value to my session array instead of overwriting the one that is presently there. I am basically trying to create a shopping cart that uses the product name as the $key and the quantity as the $value.
🙂
/// User clicks on a form and two details are sent ///
$p = $_GET[name];
$q = $_GET[Quantity];
/// Session array is created ///
$_SESSION['cart'][] = array(
$p => $q
);
foreach ($_SESSION['cart'] as $value)
{
foreach ($value as $name => $qty)
{
echo $name . ' ' . $qty . '<br>';
}
echo '<br>';
}