Skip to content
Advertisement

PHP Shopping cart // show results of different rows

Hell community, I am trying to build up a shopping cart which basically looks like an excel table. The layout and the main code is working good but I can add only products from one row to the shopping cart table. My target is to choose and add as much products I want from row I want.

Here the code I am using:

JavaScript

What I have found out is that when I cklick th “Add to cart” button my code shows always only the content in the shopping cart table of the variable which is mentioned in the “hidden_price” row. What do I have to add or change in the code to be able to add also the other rows (B, C, D…) to the shopping cart and to be able to choose a product from the row I want?

Thanks upfront for your support!

Advertisement

Answer

What you are trying to do is not working this wat. You should either have a different form for each product wether use checkbox. Below is the code for the first case. Keep in mind name is how you call the field and value is “what you want to get from that field**.

When you use POST , you do not need something after action=”somefile.php” this is what post does, “send all variables to the file somefile.php”. Only problem with the below is that you need your tbl_sc.php after “posting” the data to redirect in the same page.

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement