omegaultmo2 Posted January 26, 2012 Share Posted January 26, 2012 The web application should allow the user to view the items in a catalogue, add items to a shopping cart, remove items from the shopping cart, and to view the contents of the shopping cart. Hey guys. Right ill try explain as best i can. Basicly we were told to write a php script that can view a shopping cart. The items in the catalogue should be stored as an array of objects. (The next assignment will require you to store this list of objects in a database). There should also be pages to allow the user to add, edit and delete items in the catalogue. Thats taken from a brief.Ive spent the most of the week getting it to view a catalog and now it can add items.view the cart its added them to and remove them from the cart and return. What im having trouble with is making the add function for the the other users or admin* to add/edit/delete.i reckoned adding and deleting wouldnt be so bad considering ive alrready done so.But im kinda stumped on how to do it.i think what the brief wanted was a seprate product add that would actully let u add another product to the cart list on the same page and then u can add that to the shopping basket etc. Yea real stumped.if only it was through sql it would be so much handier. ill post the code below.if anyone can help at all in the slightest id be so grateful.Thank you. 17429_.zip Quote Link to comment https://forums.phpfreaks.com/topic/255839-adding-a-add-and-remove-function-for-a-product-category/ Share on other sites More sharing options...
Psycho Posted January 26, 2012 Share Posted January 26, 2012 Yeah, if you are storing the products in an array, presumably in the PHP file, then the ability to add/edit/delete products is kinda weird. Of course you could always store the array in a separate file and create the processes to modify that file. But, that's really a waste of time since you are going to move into a database in the next step. Personally, I would ask the instructor for clarification on what the expectations are. I assume you are storing the cart information in a session variable. You could do the same thing for the product data. So, when a page is loaded you check to see if the complete product list has been saved to a session variable. If not, do that. Then when an "admin" makes changes to the products, those changes are made to the session data. Of course, none of these changes would be seen by "other" users accessing the pages on a different machine/browser and the changes would be wiped out when you closed the browser. But, again, this is just an exercise to get you to the next step using a database. Quote Link to comment https://forums.phpfreaks.com/topic/255839-adding-a-add-and-remove-function-for-a-product-category/#findComment-1311477 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.