Payment cart using array to post product order and price | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Payment cart using array to post product order and price

Creating a shopping website On my order list I have different products with their price Like Digital camera $80 Smart phone $ 140 Audio speaker $300 Question is how do I send each product to display on a separate row on MySQL database

8th Jan 2019, 1:18 PM
Brown
Brown - avatar
6 Answers
+ 1
Can you provide code? Maybe an attempt to see what we're working with.
10th Jan 2019, 2:13 AM
Ben Allen (Njinx)
Ben Allen (Njinx) - avatar
+ 1
<?php include("config.php"); $sql = "SELECT sell_id, price, product, name, img, imgrand FROM sell WHERE NOT EXISTS ( SELECT * FROM sell t WHERE t.imgrand = sell.imgrand AND t.sell_id = sell.sell_id - 1 ) ORDER BY sell_id"; $result = mysqli_query($link, $sql); if ($result->num_rows > 0){ while($row = $result->fetch_assoc()) { echo '<div class="col-md-3 product-grids"> <div class="agile-products"> <div class="new-tag"><h6>20%<br>Off</h6></div> <a href="#/descr.php?imgrand='.$row["imgrand"].'"><img src="#/'.$row["img"].'" class="img-responsive" alt="img"></a> <div class="agile-product-text"> <h5><a href="#/descr.php?imgrand='.$row["imgrand"].'">'.$row["product"].'</a></h5> <h6>
#x27;.$row["price"].'</h6> <form action="" method="post"> <input type="hidden" name="cmd" value="_cart" /> <input type="hidden" name="add" value="1" /> <input type="hidden" name="w3ls_item" value="'.$row["product"].'" /> <input type="hidden" name="amount" value="'.$row["price"].'" /> <button type="submit" class="w3ls-cart pw3ls-cart"><i class="fa fa-cart-plus" aria-hidden="true"></i> Add to cart</button> </form> </div> </div> </div>'; } } ?>
10th Jan 2019, 2:23 AM
Brown
Brown - avatar
+ 1
i want to add checkout functionality and how also need assistance on how to add the the individual product and price on a separate row on my order table in my database.
10th Jan 2019, 2:25 AM
Brown
Brown - avatar
+ 1
I'm going to be completely honest, I can't read your code. Please take some time to refractor it. But generally how it would be done is using a foreach loop. If you're not sure what that is check the docs.
10th Jan 2019, 2:34 AM
Ben Allen (Njinx)
Ben Allen (Njinx) - avatar
0
docs? please where is it?
10th Jan 2019, 3:54 AM
Brown
Brown - avatar
0
The official PHP docs. Just do a quick google search.
10th Jan 2019, 4:16 AM
Ben Allen (Njinx)
Ben Allen (Njinx) - avatar