I'm having an array which I have included only once in the header.php
file.
header.php:
<?
session_start();
include_once("array.php");
?>
array.php:
<?$foo["cart"] = array();?>
In the order.php
I'm having an array and code which is executed when submitting a form. After the array_push
you'll be redirected to the webshop.php
, where you can view your shoppingcard.
order.php:
<?
array_push($foo["cart"], array ('imagename'=>"$imagename",'size'=>"$size", 'price'=> "$price")); $_SESSION["order"] = $foo;
?>
webshop.php:
<div class="shopping-card" >
<? echo "<ol>";
for ($row = 0; $row < 3; $row++)
{
echo "<li><b>Products:</b>";
echo "<ul>";
foreach( $_SESSION["order"]["cart"][$row] as $key => $value)
{
echo "<li>".$value."</li>";
}
echo "</ul>";
echo "</li>";
}
echo "</ol>";
?>
</div>
As you can see here, it only shows the last value.
I hope you guys can help me out.