Warning: A non-numeric value encountered in D: mpp runninghtdocsprojectsMyShopcart.php on line 126
1. <?php
2. include("includes/db.php");
3. include("functions/functions.php");
4. ?>
5. <!DOCTYPE html>
6. <html>
7. <head>
8. <meta http-equiv= content="text/html; charset=utf-8">
9. <title>My First Project</title>
10.
11. <link rel= type="text/css" href="styles/style.css" media="all"/>
12.
13. </head>
14. <body>
15.
16. <!--------------Main container Starts--------->
17. class="main_wrapper">
18.
19. <!----------Header starts----------------->
20. <div class="header_wrapper">
21. <a href="index.php"><img src="images/nav1.jpg" style="float: left;"></a>
22. <img src="images/nav2.jpg" style="float: right;">
23. </div>
24. <!----------Header stops----------------->
25.
26. <!----------navbar starts-------------->
27. <div id="navbar">
28. <ul id="menu">
29. <li><a href="index.php">Home</a></li>
30. <li><a href="all_products.php">All Products</a></li>
31. <li><a href="my_account.php">My Account</a></li>
32. <li><a href="user_register.php">Sign Up</a></li>
33. <li><a href="cart.php">Shopping Cart</a></li>
34. <li><a href="contact.php">Contact Us</a></li>
35. </ul>
36.
37.
38. <div id="form">
39. <form method="get" action="results.php" enctype="multipart/form-data">
40. <input type="text" name="user_query" placeholder="Search a Products"/>
41. <input type="submit" name="search" value="search"/>
42. </form>
43. </div>
44. </div>
45. <!----------navbar stops--------------->
46.
47.
48. <div class="content_wrapper">
49. <div id="left_sidebar">
50. <div id="sidebar_title">Categories</div>
51. <ul id="cats">
52. <?php
53. getCats();
54. ?>
55.
56. </ul>
57.
58. <div id="sidebar_title">Brands</div>
59. <ul id="cats">
60. <?php
61. getBrands();
62.
63. ?>
64. </ul>
65. </div>
66. <div id="right_content">
67. <?php
68. cart();
69. ?>
70. <div id="headline">
71. <div id="headline_content">
72. <b>Welcome Guest</b>
73. <b style="color: yellow;">Shopping Cart:</b>
74. <span>- Items:<?php items(); ?> - Total Price: <?php total_price();?> - <a href="cart.php" style="color: #FF0; padding-right: 10px;">Go to Cart</a></span>
75. </div>
76. </div>
77.
78.
79.
80. <div id="products_box"><br>
81. <form action="cart.php" method="POST" enctype="multipart/form-data">
82. <table width="780" align="center" bgcolor="#0099CC" style="margin: 10px">
83. <tr align="center">
84. <td><b>Remove</b></td>
85. <td><b>Product</b></td>
86. <td><b>Quantity</b></td>
87. <td><b>Total Price</b></td>
88. </tr>
89. <?php
90. $ip_add=getRealIpAddr();
91. $total=0;
92. $sel_price="SELECT * FROM `cart` WHERE ip_add='$ip_add'";
93. $run_price=mysqli_query($con, $sel_price);
94. while($record=mysqli_fetch_array($run_price))
95. {
96. $pro_id=$record['p_id'];
97. $pro_price="SELECT * FROM `products` WHERE product_id='$pro_id'";
98. $run_pro_price=mysqli_query($db,$pro_price);
99. while($p_price=mysqli_fetch_array($run_pro_price))
100. {
101. $product_price=array($p_price['product_price']);
102. $product_title=$p_price['product_title'];
103. $product_image=$p_price['product_img1'];
104. $only_price=$p_price['product_price'];
105.
106. $values=array_sum($product_price);
107. $total +=$values;
108.
109. ?>
110.
111.
112. "center"><input type= name="remove[]" value="<?php echo $pro_id;?>">
113. "center"><?php echo $product_title; ?>
"admin_area/product_images/<?php echo $product_image; ?>" height="80px" width="80px">
114. "center"><input type= name="qty" value="" size="5">
115.
116.
117.
118. <?php
119.
120. if (isset($_POST['update'])) {
121. $qty=$_POST['qty'];
122. $insert_qty="UPDATE `cart` SET 'qty'='$qty' WHERE 'ip_add'='$ip_add'";
123. $run_qty=mysqli_query($con, $insert_qty);
124.
125.
126. $total=$total*$qty;
127.
128. }
129.
130.
131. ?>
132.
133.
134.
135.
136. "center"><?php echo "$" . "$only_price";?>
137.
138.
139. <?php }} ?>
140.
141. "3" align="right" style="padding-right:0px";>Sub Total:
142. "padding-left:65px";><?php echo "$" . "$total";?>
143.
144.
145.
146.
147.
148. "center"><input type= name="update" value="Update Cart"/>
149. "center"><input type= name="continue" value="Continue Shopping"/>
150. "center"><button>"checkout.php" style="text-decoration: none; color: #000;">Checkout</button>
151.
152.
153. </form>
154. <?php
155. function updatecart()
156. {
157. global $con;
158.
159. if (isset($_POST['update']))
160. {
161. foreach ($_POST['remove'] as $remove_id)
162. {
163. $delete_products="DELETE FROM `cart` WHERE p_id='$remove_id'";
164. $run_delete=mysqli_query($con, $delete_products);
165. if ($run_delete)
166. {
167. echo "[removed]window.open('cart.php','_self')[removed]";
168.
169. }
170. }
171.
172. }
173. if (isset($_POST['continue']))
174. {
175. echo "[removed]window.open('index.php','_self')[removed]";
176. }
177. }
178. echo @$up_cart=updatecart();
179. ?>
180.
181.
182.
183.