mikhl Posted February 14, 2011 Share Posted February 14, 2011 For a project I have to create a simple form that allows a user to order a pair of trainers. I understand how to do as the project outlines, but would like to expand on it. Would it be possible for me to substitute a MySQL database for an array that contains an array of products. So that when the user makes an order, the quantity in the array is reduced. The array would look as follows: $prod = array( array( 'id' => '00001', 'name' => 'Pink Converse', 'desc' => 'This is the description of the product.', 'price' => 4500, 'quantity' => 2, 'img' => 'images/prod1.jpg', 'img2' => 'images/00001-2.jpg' ), array( 'id' => '00002', 'name' => 'Tartan Nike Hi-Tops', 'desc' => 'This is the description of the product.', 'price' => 5500, 'quantity' => 2, 'img' => 'images/prod2.jpg', 'img2' => 'images/00002-2.jpg' ), array( 'id' => '00003', 'name' => 'Black Hi-Tops', 'desc' => 'This is the description of the product.', 'price' => 5500, 'quantity' => 2, 'img' => 'images/prod3.jpg', 'img2' => 'images/00003-2.jpg' ), array( 'id' => '00004', 'name' => 'Smart Mens Shoes', 'desc' => 'This is the description of the product.', 'price' => 7000, 'quantity' => 2, 'img' => 'images/prod3.jpg', 'img2' => 'images/00004-2.jpg' ) ); If you know if this is possible or not, you would be a great help, any ideas would also be welcome. Thanks Link to comment https://forums.phpfreaks.com/topic/227660-php-shopping-cart-without-database/ Share on other sites More sharing options...
ignace Posted February 14, 2011 Share Posted February 14, 2011 Quote Would it be possible for me to substitute a MySQL database for an array that contains an array of products. No. An array is not a persistent storage device: Everytime the user would reload the page, the quantity would be reset to it's original value. Why do you want to use an array instead of a DB? Link to comment https://forums.phpfreaks.com/topic/227660-php-shopping-cart-without-database/#findComment-1174235 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.