-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcart.php
82 lines (81 loc) · 3.43 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
<?php
session_start();
require 'connection.php';
if(!isset($_SESSION['email'])){
header('location: login.php');
}
$user_id=$_SESSION['id'];
$user_products_query="select it.id,it.name,it.price from users_items ut inner join items it on it.id=ut.item_id where ut.user_id='$user_id'";
$user_products_result=mysqli_query($con,$user_products_query) or die(mysqli_error($con));
$no_of_user_products= mysqli_num_rows($user_products_result);
$sum=0;
if($no_of_user_products==0){
//echo "Add items to cart first.";
?>
<script>
window.alert("No items in the cart!!");
</script>
<?php
}else{
while($row=mysqli_fetch_array($user_products_result)){
$sum=$sum+$row['price'];
}
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" href="img/lifestyleStore.png" />
<title>Lifestyle Store</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- latest compiled and minified CSS -->
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" type="text/css">
<!-- jquery library -->
<script type="text/javascript" src="bootstrap/js/jquery-3.2.1.min.js"></script>
<!-- Latest compiled and minified javascript -->
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
<!-- External CSS -->
<link rel="stylesheet" href="css/style.css" type="text/css">
</head>
<body>
<div>
<?php
require 'header.php';
?>
<br>
<div class="container">
<table class="table table-bordered table-striped">
<tbody>
<tr>
<th>Item Number</th><th>Item Name</th><th>Price</th><th></th>
</tr>
<?php
$user_products_result=mysqli_query($con,$user_products_query) or die(mysqli_error($con));
$no_of_user_products= mysqli_num_rows($user_products_result);
$counter=1;
while($row=mysqli_fetch_array($user_products_result)){
?>
<tr>
<th><?php echo $counter ?></th><th><?php echo $row['name']?></th><th><?php echo $row['price']?></th>
<th><a href='cart_remove.php?id=<?php echo $row['id'] ?>'>Remove</a></th>
</tr>
<?php $counter=$counter+1;}?>
<tr>
<th></th><th>Total</th><th>Rs <?php echo $sum;?>/-</th><th><a href="success.php?id=<?php echo $user_id?>" class="btn btn-primary">Confirm Order</a></th>
</tr>
</tbody>
</table>
</div>
<br><br><br><br><br><br><br><br><br><br>
<footer class="footer">
<div class="container">
<center>
<p>Copyright © Nutrition Store. All Rights Reserved. | Contact Us: +91 90000 00000</p>
<p>This website is developed by Aakash Kumar</p>
</center>
</div>
</footer>
</div>
</body>
</html>