-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewcart.php
executable file
·64 lines (51 loc) · 1.59 KB
/
viewcart.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
<?php
include 'header.php';
echo "<br><br><br><br><br>";
session_start();
require 'db.php';
$imgurl = "img/";
$grandtotal = 0;
foreach ($_SESSION['cart'] as $product) {
$sql = " SELECT * FROM product WHERE id='" .$product['id'] ."' ";
$result = $conn->query($sql);
?>
<table>
<tr>
<?php
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$total = $product['qty'] * $row['price'];
?>
<form action="checkout.php" method="get">
<td>
Name : <?= $row['name'] ?> <br>
Price : <?= $row['price'] ?> <br>
Qtty : <?= $product['qty'] ?> <br>
Total : <?= $total ?>
</td>
<td>
<img src=" <?= $imgurl.$row['image'] ?>" height="110" width="100" >
</td>
</tr>
<tr></tr>
<?php
}
}
$grandtotal += $total;
}
$_SESSION['grndtotal'] = $grandtotal;
$conn->close();
?>
<tr>
<td>
Grand Total : <?= $grandtotal ?>
</td>
</tr>
<tr><td></td> </tr>
<tr>
<td>
<input type="submit" name="btncheckout" value="Checkout & Proceed">
</td>
</form>
</tr>
</table>