-
Notifications
You must be signed in to change notification settings - Fork 0
/
cart.php
114 lines (93 loc) · 3.05 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
<?php
session_start();
if(!isset($_SESSION['id']))
{
echo "test";
header("Location: signin.php");
exit();
}
$subtotal = 0;
?>
<!DOCTYPE HTML>
<!--
Snapshot by TEMPLATED
templated.co @templatedco
Released for free under the Creative Commons Attribution 3.0 license (templated.co/license)
-->
<html>
<head>
<title>KEEBARD</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="assets/css/main.css" />
</head>
<body>
<div class="page-wrap">
<!-- Nav -->
<nav id="nav">
<ul>
<li><a href="index.php"><span class="icon fa-home"></span></a></li>
<li><a href="store.php"><span class="icon fas fa-tags"></span></a></li>
<li><a href="signin.php"><span class="icon fas fa-user"></span></a></li>
<li><a href="cart.php" class="active"><span class="icon fa-shopping-cart"></span></a></li>
</ul>
</nav>
<!-- Main -->
<section id="main">
<div class="inner">
<header>
<h1>Shopping Cart</h1>
</header>
</div>
<section id="galleries">
<div class="gallery">
<div class="content" style="text-align: center;">
<?php
require_once 'php/database.php';
$result = $connection->query("SELECT * FROM carts WHERE user_id={$_SESSION['id']}");
$num_rows = $result->num_rows;
for($i = 0 ; $i < $num_rows ; ++$i)
{
$row = $result->fetch_assoc();
$result2 = $connection->query("SELECT * FROM products WHERE id={$row['product_id']}");
$item = $result2->fetch_assoc();
$total = $row['quantity'] * $item['price'];
$subtotal = $subtotal + $total;
echo "
<div class=\"media\">
<img style=\"width: 50%;\" src={$item['image']} alt=\"\"/>
<h3>{$item['pname']}</h3>
<form method=\"POST\" action=\"php/remove.php\">
<label>Price: \${$item['price']}</label>
<label>Qtty: {$row['quantity']}</label>
<label>Total: \$$total </label>
<input type=\"hidden\" name=\"cart_id\" id=\"cart_id\" value={$row['id']} >
<br><input value=\"remove\" type=\"submit\" />
</form> </div>
";
}
?>
</div>
<footer>
<h1>Subtotal: $<?php echo $subtotal; ?></h1>
<a href="php/purchase.php" class="button big">Purchase</a>
</footer>
</div>
</section>
<!-- Footer -->
<footer id="footer">
<div class="copyright">
© Untitled Design: <a href="https://templated.co/">TEMPLATED</a>. Images: <a href="https://unsplash.com/">Unsplash</a>.
</div>
</footer>
</section>
</div>
<!-- Scripts -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/jquery.poptrox.min.js"></script>
<script src="assets/js/jquery.scrolly.min.js"></script>
<script src="assets/js/skel.min.js"></script>
<script src="assets/js/util.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>