1.Write the possible value
of variable $con, which first appears at line 11 and
then line 36.
2. Write the minimum columns of the data structure of the two
tables “ cart” and “products”, which you can get from the code.
3.Describe the full process of “cart.php” code with a
flowchart.
1 <?php 2 $activ='Cart'; 3 include("includes/header.php"); 4 ?> 5 ▾ <div id="content"><!--#content begin--> 6 <h1>Shopping Cart</h1> 7 8 <?php 9 $ip_add = getRealIpUser(); 10 $select_cart = "select * from cart where ip_add='$ip_add""; 11 $run_cart= mysqli_query($con, $select_cart); 12 $count = mysqli_num_rows($run_cart); 13 ?> 14 15 <p class="text-muted">You currently have <?php echo $count; ?> item(s) in your cart</p> 16 ▾ <div class="table-responsive"><!--table-responsive Begin--> 17 ▾ <form action="cart.php" method="post" enctype="multipart/form-data"><!--form Begin--> 18 <table class="table"><!--table begin--> 19 ▼ <tr><!--tr begin--> 20 <th colspan="2">Product</th> 21 <th>Quantity</th> 22 <th>Unit Price</th> 23 <th>Size</th> 24 <th colspan="1">Delete</th> 25 <th colspan="2">Sub-Total</th> 26 </tr><!--tr Finish--> 27 ▼ <tbody><!--tbody begin--> 28 29 <?php 30 $total = 0; 31 ▼ while ($row_cart = mysqli_fetch_array($run_cart)) { 32 $pro_id = $row_cart['p_id']; 33 $pro_size = $row_cart['size']; 34 $pro_qty = $row_cart['qty']; 35 $get_products = "select * from products where product_id='$pro_id'"; $run_products = mysqli_query($con, $get_products); 36 37 38 V while ($row_products = mysqli_fetch_array($run_products)) { 39 $product_title = $row_products ['product_title']; 40 $product_img1 = $row_products ['product_img1']; 41 $only_price = $row_products ['product_price']; 42 $sub_total = $row_products['product_price'] *$pro_qty; Stotal + $sub_total; 43 44 45 46 ▼ <tr><!--tr begin--> 47 48 <td><img class="img-responsive" src="admin_area/product_imgages/<?php echo $product_img1; ?>"></td> <td><a href="details.php?pro_id=<?php echo $pro_id; ?>"> <?php echo $product_title; ?> </a></td> <td><?php echo $pro_qty; ?></td> 49 50 <td><?php echo $only_price; ?></td> 51 <td><?php echo $pro_size; ?></td> 52 <td><input type="checkbox" name="remove []" value="<?php echo $pro_id; ?>"></td> 53 <td><?php echo $sub_total; ?></td> 54 55 56 57 V 58 V 59 <th colspan="5">Total</th> 60 <th colspan="2">$<?php echo $total; ?></th> 61 62 63 ?> </tr><!--tr finish--> <?php } } ?> </tbody><!--tbody finish--> <tfoot><!--tfoot begin--> <tr><!--tr begin--> </tr><!--tr finish--> </tfoot><!--tfoot finish--> </table> <!--table finish-->
64 65 66 ▼ 67 ▼ 68 69 70 71 72 75 70 ▼ 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 </div><!--table-responsive finish--> <div class="box-footer"><!--box-footer <div clss="pull-left"> begin--> <a href="index.php" class="btn btn-default"><i class="fa fa-chevron-left"></i> Continue Shopping</a> </div><!--pull-left finish--> <div class="pull-right"><!--pull-right begin--> <button type="submit" name="update" value="Update Cart" class="btn btn-default"> <i class="fa fa-refresh"></i> Update Cart </button> <a href="checkout.php" class="btn btn-primary">Proceed Checkout<i class="fa fa-chevron-right"></i></a> </div><!--pull-right finish--> </div><!--box-footer finish--> </form> <!--from finish--> </div><!--#content begin--> <?php function update_cart() { global $con; foreach ($_POST['remove'] as $remove_id) { $delete_product = "delete from cart where p_id='$remove_id'"; $run_delete = mysqli_query($con, $delete_product); if($run_delete) { echo "<script>window.open('cart.php', '_self') </script>; } } } } echo @$up_cart=update_cart(); include("includes/footer.php"); ?> <script src="js/jquery-331.min.js"></script> <script src="js/bootstrap-337.min.js"></script> </body> </html> if(isset($_POST['update'])) {
1.Write the possible value of variable $con, which first appears at line 11 and then line 36. 2. Write the minimum colu
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am