Hi all,
I’m trying to make a php shopping cart, for my task I have been told to use arrays (I know it should be in a database), however, at current I have all the products in an array and within a table and links for adding to a cart.
My only issue is that I have no idea how to add the items to a “cart”, baring in mind these items need to remain temporarily stored as I would like them to be used in a summary screen upon clicking Submit.
[php]<?php
$Item1 = array(‘SKU’=>test1, ‘name’=>ProductTest1, ‘Price’=>10.00);
$Item2 = array(‘SKU’=>test2, ‘name’=>ProductTest2, ‘Price’=>11.00);
$Item3 = array(‘SKU’=>test3, ‘name’=>ProductTest3, ‘Price’=>12.00);
?>
SKU | Name | Price | Action |
---|---|---|---|
<?php echo $Item1[SKU]; ?> | <?php echo $Item1[name]; ?> | <?php echo '£'. number_format($Item1[Price],2); ?> | Add To Cart |
<?php echo $Item2[SKU]; ?> | <?php echo $Item2[name]; ?> | <?php echo '£'. number_format($Item2[Price],2); ?> | Add To Cart |
<?php echo $Item3[SKU]; ?> | <?php echo $Item3[name]; ?> | <?php echo '£'. number_format($Item3[Price],2); ?> | Add To Cart |
I am pretty new to PHP however, any help would be GREATLY appriciated.
Thank You