-
Notifications
You must be signed in to change notification settings - Fork 0
/
cart.php
70 lines (68 loc) · 2.89 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
<!DOCTYPE html>
<?php
require 'includes/common.php';
if(!isset($_SESSION['id']))
{
header('location: index.php');
}
?>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Cart | Life Style Store</title>
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
</head>
<body>
<div class="container-fluid" id="content">
<?php
include 'includes/header.php';
?>
<div class="row decor_bg">
<div class="col-md-6 col-md-offset-3">
<table class="table table-striped">
<?php
$user_id = $_SESSION['id'];
$query = "SELECT * FROM users_items as ui INNER JOIN items as i on user_id = '$user_id' AND ui.item_id = i.id and status = 'Added to cart';";
$result = mysqli_query($con, $query) or die(mysqli_error($con));
$sum = 0;
$id = "";
if(mysqli_num_rows($result)==0)
{
echo "<center><h1>Add items to cart first!</h1></center>";
}
else
{
?>
<thead>
<tr>
<th>Item Number</th>
<th>Item Name</th>
<th>Price</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
while ($row = mysqli_fetch_array($result))
{
$sum+= $row["price"];
$id .= $row["id"] . ",";
echo "<tr><td>" . "#" . $row["id"] . "</td><td>" . $row["name"] . "</td><td>Rs " . $row["price"] . "</td><td><a href='cart-remove.php?id={$row['id']}' class='remove_item_link'> Remove</a></td></tr>";
}
$id = rtrim($id, ", ");
echo "<tr><td></td><td>Total</td><td>Rs " . $sum . "</td><td><a href='success.php?itemsid=" . $id . "' class='btn btn-primary'>Confirm Order</a></td></tr>";
}
?>
</tbody>
</table>
</div>
</div>
</div>
<?php
include 'includes/footer.php';
?>
</body>
</html>