-
Notifications
You must be signed in to change notification settings - Fork 0
/
cart.php
86 lines (60 loc) · 1.73 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
<!-- head -->
<?php include_once"templating/head.php" ?>
<!-- Navigation -->
<?php include_once"templating/main_nav.php" ?>
<!-- Page Content -->
<div class="container">
<div class="row justify-content-center">
<div class="col-lg-12 pb-5 pt-5">
<?php if(!empty($_SESSION['cart'])) { ?>
<table>
<tr>
<th> </th>
<th class="text-center">Product Name</th>
<th class="text-center">Price</th>
<th class="text-center">Details</th>
<th class="text-center">Action</th>
<!-- <th></th> -->
</tr>
<?Php
include_once "php/DB/DB_Connection.php";
$conn = DataBaseConnection();
foreach ($_SESSION['cart'] as $product) {
$sql = "SELECT * FROM products WHERE id = $product";
$result = $conn->query($sql);
// $total;
foreach($result AS $row){
?>
<tr>
<td><img src="img/<?=$row['Image']?>" alt=""></td>
<td><?=$row['name']?></td>
<td>$ <?=$row['price']?></td>
<td><?=$row['details']?></td>
<td class="d-flex justify-content-between">
<a class="btn btn-danger text-light" href="php/removeFromCart.php?pid=<?=$row['Id']?>">
Remove
</a>
</td>
</tr>
<?php
// $total += (int)$row['price'];
}
}
if (isset($_SESSION['msg'])) {
echo($_SESSION['msg']);
unset($_SESSION['msg']);
}
?>
</table>
<?php }
else{
header("location:index.php");
}
?>
</div>
</div>
<!-- /.row -->
</div>
<!-- /.container -->
<!-- Footer -->
<?php include_once"templating/footer_area.php" ?>