-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
207 lines (178 loc) · 6.29 KB
/
index.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="author" content="Sahil Kumar">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Shopping Cart System</title>
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.min.css' />
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/all.min.css' />
</head>
<body>
<!-- Navbar start -->
<nav class="navbar navbar-expand-md bg-dark navbar-dark">
<a class="navbar-brand" href="index.php"><i class="fas fa-mobile-alt"></i style="font-family:'Monaco'"> Spy Empire</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link active" href="index.php"><i class="fas fa-mobile-alt mr-2"></i>Products</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#"><i class="fas fa-th-list mr-2"></i>Categories</a>
</li>
<li class="nav-item">
<a class="nav-link" href="checkout.php"><i class="fas fa-money-check-alt mr-2"></i>Checkout</a>
</li>
<li class="nav-item">
<a class="nav-link" href="cart.php"><i class="fas fa-shopping-cart"></i> <span id="cart-item" class="badge badge-danger"></span></a>
</li>
</ul>
</div>
</nav>
<!-- Navbar end -->
<style>
.container {
position: relative;
text-align: center;
color: white;
}
.bottom-left {
position: absolute;
bottom: 8px;
left: 16px;
}
.top-left {
position: absolute;
top: 8px;
left: 16px;
}
.top-right {
position: absolute;
top: 8px;
right: 16px;
}
.bottom-right {
position: absolute;
bottom: 8px;
right: 16px;
}
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
</head>
<body>
<div class="container">
<img src="one.jpg" alt="Snow" style="width:100%;">
<div> <p><b style="color:grey;" >“LOOKS LIKE WE'VE GOT ANOTHER MYSTRY ON OUR HANDS”</b></p></div>
<marquee style="color:red" font-size="70px;" ><b>TIMES OF INDIA: Private detective agency owner, staffer held for ‘stalking’ woman</b> </marquee>
</div>
</body>
</html>
<!-- Displaying Products Start -->
<div class="container">
<div id="message"></div>
<div class="row mt-2 pb-3">
<?php
include 'config.php';
$stmt = $conn->prepare('SELECT * FROM product');
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()):
?>
<div class="col-sm-6 col-md-4 col-lg-3 mb-2">
<div class="card-deck">
<div class="card p-2 border-secondary mb-2">
<img src="<?= $row['product_image'] ?>" class="card-img-top" height="250">
<div class="card-body p-1">
<h4 class="card-title text-center text-info"><?= $row['product_name'] ?></h4>
<h5 class="card-text text-center text-danger"><i class="fas fa-rupee-sign"></i> <?= number_format($row['product_price'],2) ?>/-</h5>
</div>
<div class="card-footer p-1">
<form action="" class="form-submit">
<div class="row p-2">
<div class="col-md-6 py-1 pl-4">
<b>Quantity : </b>
</div>
<div class="col-md-6">
<input type="number" class="form-control pqty" value="<?= $row['product_qty'] ?>">
</div>
</div>
<input type="hidden" class="pid" value="<?= $row['id'] ?>">
<input type="hidden" class="pname" value="<?= $row['product_name'] ?>">
<input type="hidden" class="pprice" value="<?= $row['product_price'] ?>">
<input type="hidden" class="pimage" value="<?= $row['product_image'] ?>">
<input type="hidden" class="pcode" value="<?= $row['product_code'] ?>">
<button class="btn btn-info btn-block addItemBtn"><i class="fas fa-cart-plus"></i> Add to
cart</button>
</form>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
</div>
<!-- Displaying Products End -->
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/js/bootstrap.min.js'></script>
<script type="text/javascript">
$(document).ready(function() {
// Send product details in the server
$(".addItemBtn").click(function(e) {
e.preventDefault();
var $form = $(this).closest(".form-submit");
var pid = $form.find(".pid").val();
var pname = $form.find(".pname").val();
var pprice = $form.find(".pprice").val();
var pimage = $form.find(".pimage").val();
var pcode = $form.find(".pcode").val();
var pqty = $form.find(".pqty").val();
$.ajax({
url: 'action.php',
method: 'post',
data: {
pid: pid,
pname: pname,
pprice: pprice,
pqty: pqty,
pimage: pimage,
pcode: pcode
},
success: function(response) {
$("#message").html(response);
window.scrollTo(0, 0);
load_cart_item_number();
}
});
});
// Load total no.of items added in the cart and display in the navbar
load_cart_item_number();
function load_cart_item_number() {
$.ajax({
url: 'action.php',
method: 'get',
data: {
cartItem: "cart_item"
},
success: function(response) {
$("#cart-item").html(response);
}
});
}
});
</script>
</body>
<footer>
<center>
<p style="font-family:'Monaco'" ><b>Created by TEAM RED. © 2023</b></p>
</center>
</footer>
</html>