-
Notifications
You must be signed in to change notification settings - Fork 0
/
cart.php
182 lines (152 loc) · 5.41 KB
/
cart.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<?php
include 'config.php';
error_reporting(0);
$sql="SELECT *FROM `order`";
$result=mysqli_query($conn,$sql);
$row=mysqli_fetch_assoc($result);
$oid=$row['id'];
$sphone =$row['sphone'];
$pname=$row['pname'];
$price=$row['price'];
$quantity=$row['quantity'];
$total=$row['total'];
$cphone=$row['cphone'];
if(isset($_POST['update'])){
$oid=$row['id'];
$sphone =$row['sphone'];
$pname=$row['pname'];
$price=$row['price'];
$quantity = $_POST['quantity'];
$total=$quantity*$price;
$cphone=$row['cphone'];
$sql="UPDATE `order` SET id='$oid', sphone='$sphone',pname='$pname',price='$price',quantity='$quantity',total='$total',cphone='$cphone' WHERE pname='$pname'";
$res=mysqli_query($conn,$sql);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Cart</title>
<link rel="stylesheet" href="style.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;500;600;700&display=swap" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="navbar">
<div class="logo">
<a href="index.php"><img src="images/logo.png" width ="125px"></a>
</div>
<nav>
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="product.php">Products</a></li>
<li><a href="aboutus.php">About</a></li>
<li><a href="contact.php">Contact</a></li>
<li><a href="slogin.php">Seller Account</a></li>
<li><a href="clogin.php">Customer Account</a></li>
</ul>
</nav>
<a href="cart.php"><img src="images/cart.png" width="30px" height="30px"></a>
</div>
</div>
<!-----------------------------cart------------------------------>
<div class="small-container cart-page">
<table>
<tr>
<th>Product</th>
<th>Quantity(In kg)</th>
<th>Total</th>
</tr>
<tbody>
<?php
$sq="SELECT order.pname,order.quantity,order.price,order.total,product.picture FROM `order`,`product` WHERE product.pname=order.pname";
$result=mysqli_query($conn,$sq);
$num=mysqli_num_rows($result);
if($num>0){
while( $row=mysqli_fetch_assoc($result)){
$pname=$row['pname'];
$price=$row['price'];
$quantity=$row['quantity'];
$picture=$row['picture'];
$total=$row['total'];
echo ' <tr>
<td><div class="cartinfo">
<img src="images/'. $picture.'">
<div>
<p>'.$pname.'</p>
<small>Price: Rs. '.$price.'</small>
<br>
<a href="deletefromcart.php?deleteproduct='.$pname.'">Remove</a>
</div>
</div></td>
<td>
<form action="" method="post">
<input type="number" min="2" max="500" name="quantity" value='.$quantity.'>kg
<button name="update" type="submit">Update</button>
</form></td>
<td>Rs. '.$total.'</td>
</tr>';
}
}
?>
</tbody>
</table>
<div class="total-price">
<table>
<tr>
<td>Total</td>
<td><?php
$sql="SELECT SUM(total) AS summ FROM `order`";
$result=mysqli_query($conn,$sql);
while ($row =mysqli_fetch_assoc($result)){
echo 'Rs. '.$row['summ'].'';
}
?>
</td>
</tr>
<tr>
<td></td>
<td>
<?php
$sq="SELECT cphone from `order`";
$result=mysqli_query($conn,$sq);
$num=mysqli_num_rows($result);
if($num>0){
while( $row=mysqli_fetch_assoc($result)){
$cphone=$row['cphone'];
}
}
echo'<a href="Confirmation.php?cid='.$cphone.'" class= "btn-order"> Preview </a>';
?>
</td>
</tr>
</table>
</div>
</div>
<!------------------------------------footer-------------------------------->
<div class="footer">
<div class="container">
<div class="row">
<div class="footer-col">
<h3>Follow Us On</h3>
<ul>
<li>
<a href=""><img src="https://img.icons8.com/fluent/50/000000/facebook-new.png"/></a>
</li>
<li>
<a href=""><img src="https://img.icons8.com/fluent/48/000000/instagram-new.png"/></a>
</li>
<li>
<a href=""><img src="https://img.icons8.com/fluent/48/000000/twitter.png"/></a>
</li>
</ul>
</div>
</div>
</div>
<div class="copyright"><p>All rights reserved.</p></div>
</div>
</body>
</html>