-
Notifications
You must be signed in to change notification settings - Fork 6
/
product.php
392 lines (329 loc) · 13.5 KB
/
product.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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
<?php
session_start();
include 'connection.php';
include 'header.php';
$cust_id = 0;
$source_url = $_SERVER['QUERY_STRING'];
if(!empty($_SESSION["loggedin"])){
$cust_id = $_SESSION["id"];
}
$name = "";
$img = "";
$img1 = "";
$img2 = "";
$price = 0;
$sql = "SELECT pro_name, pro_img, pro_img1, pro_img2, price FROM products WHERE pro_id = $source_url";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$name = $row["pro_name"];
$img = $row["pro_img"];
$img1 = $row["pro_img1"];
$img2 = $row["pro_img2"];
$price = $row["price"];
}
}
if(isset($_POST['AddToCartBT'])){ //check if form was submitted
$size = $_POST['sizes'];
$query = "INSERT INTO cart (cus_id, pro_id, pro_size) VALUES ($cust_id, $source_url, '$size')";
if($result = mysqli_query($conn, $query)) {
echo '<div id="NotiWindow" class="Notimodal">
<div class="Notimodal-content">
<span class="Noticlose">×</span>
<p>Added to Cart!</p>
</div>
</div>';
} else {
echo '<div id="NotiWindow" class="Notimodal">
<div class="Notimodal-content">
<span class="Noticlose">×</span>
<p>Error: ' . $sql . '<br>' . $conn->error . '</p>
</div>
</div>';
}
}
?>
<html>
<body>
<!-- SIdeNav Mobile -->
<div id="mySidenav" class="sidenav">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
<input type="text" id="mySearch" onkeyup="myFunction()" placeholder="Search.." title="Type in a category">
<a href="02.html">Women</a>
<a href="02.html">Jeans</a>
<a href="02.html">Jackets</a>
<a href="02.html">Best Sales</a>
</div>
<!-- Script for SideNav Mobile -->
<script>
function openNav() {
if (document.getElementById("mySidenav").style.width == "250px") {
document.getElementById("mySidenav").style.width = "0";
} else {
document.getElementById("mySidenav").style.width = "250px";
}
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
}
</script>
<script>
// Get the modal
var modal = document.getElementById('id01');
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>
<div style="margin: 0 5%;" class="row">
<div style="width: 50%; margin: 1% 5%;" class="column02">
<div style="width: 80%;" class="slideshow-container">
<div class="mySlides fade">
<div class="numbertext">1 / 3</div>
<img src="<?php echo $img ?>" style="width:100%; border-radius: 2%;">
<!-- <div class="text">Caption Text</div> -->
</div>
<div class="mySlides fade">
<div class="numbertext">2 / 3</div>
<img src="<?php echo $img1 ?>" style="width:100%; border-radius: 2%;">
<!-- <div class="text">Caption Two</div> -->
</div>
<div class="mySlides fade">
<div class="numbertext">3 / 3</div>
<img src="<?php echo $img2 ?>" style="width:100%; border-radius: 2%;">
<!-- <div class="text">Caption Three</div> -->
</div>
<a class="pprev" onclick="plusSlides(-1)">❮</a>
<a class="pnext" onclick="plusSlides(1)">❯</a>
<div class="pdotclass" style="text-align:center">
<span class="pdot" onclick="currentSlide(1)"></span>
<span class="pdot" onclick="currentSlide(2)"></span>
<span class="pdot" onclick="currentSlide(3)"></span>
</div>
</div>
<br>
<script>
var slideIndex = 1;
showSlides(slideIndex);
function plusSlides(n) {
showSlides(slideIndex += n);
}
function currentSlide(n) {
showSlides(slideIndex = n);
}
function showSlides(n) {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("pdot");
if (n > slides.length) {
slideIndex = 1
}
if (n < 1) {
slideIndex = slides.length
}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex - 1].style.display = "block";
dots[slideIndex - 1].className += " active";
}
</script>
</div>
<div class="column">
<h2 class="prot" style="text-align:left; padding-top: 0px;"><?php echo $name ?></h2>
<p style="font-weight: 700;" class="prot">PKR <?php echo $price ?></p>
<label class="prot" for="sizes">Choose Size:</label>
<form method="post" action="">
<select class="prot" name="sizes" id="sizes">
<option value="S" selected>Small</option>
<option value="M">Medium</option>
<option value="L">Large</option>
<option value="XL">Extra Large</option>
</select>
<button type="submit" class="AddToCart" name="AddToCartBT">Add to Cart</button>
</form>
<div class="ProductRatings">
<span class="heading" style="margin-left: 12px;">User Rating</span>
<span class="fa fa-star checked"></span>
<span class="fa fa-star checked"></span>
<span class="fa fa-star checked"></span>
<span class="fa fa-star checked"></span>
<span class="fa fa-star"></span>
</div>
<p style="padding-left: 12px;">4.1 average based on 254 reviews.</p>
<hr style="border:3px solid #f1f1f1">
<div class="row">
<div class="side">
<div>5 star</div>
</div>
<div class="middle">
<div class="bar-container">
<div class="bar-5"></div>
</div>
</div>
<div class="side rright">
<div>150</div>
</div>
<div class="side">
<div>4 star</div>
</div>
<div class="middle">
<div class="bar-container">
<div class="bar-4"></div>
</div>
</div>
<div class="side rright">
<div>63</div>
</div>
<div class="side">
<div>3 star</div>
</div>
<div class="middle">
<div class="bar-container">
<div class="bar-3"></div>
</div>
</div>
<div class="side rright">
<div>15</div>
</div>
<div class="side">
<div>2 star</div>
</div>
<div class="middle">
<div class="bar-container">
<div class="bar-2"></div>
</div>
</div>
<div class="side rright">
<div>6</div>
</div>
<div class="side">
<div>1 star</div>
</div>
<div class="middle">
<div class="bar-container">
<div class="bar-1"></div>
</div>
</div>
<div class="side rright">
<div>20</div>
</div>
</div>
<p style="padding-left: 12px; margin-top: 60px;">Get 20% off your first purchase + Free Shipping and Returns with the Credit Card.</p><a style="background-color: whitesmoke; width: 92%; margin-left: 12px;" href="#">Apply Now!</a>
</div>
</div>
< <h2 style="text-align: center;">RELATED PRODUCTS</h2>
<!--Product Slideshow-->
<div class="productslideshow-container">
<div class="productmySlides">
<div class="products">
<?php
$sql = "SELECT pro_id, pro_name, price, pro_img FROM products WHERE pro_id < 6";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo '<form class="card" method="post" action="">
<input type="hidden" name="p_id" value="' .$row["pro_id"]. '" />
<a href="product.php?' . $row["pro_id"] . '">
<div class="picontainer">
<img src="'.$row["pro_img"].'" alt="Red Kurta" class="pimage">
<div class="poverlay">' . $row["pro_name"] . ' | ' . $row["price"] .'</div>
<div class="proid" style="display:none">' . $row["pro_id"] . '</div>
</div>
</a>
</form>';
}
}
?>
</div>
</div>
<div class="productmySlides">
<div class="products">
<?php
$sql1 = "SELECT pro_id, pro_name, price, pro_img FROM products WHERE pro_id > 5 Limit 5";
$result1 = $conn->query($sql1);
if ($result1->num_rows > 0) {
// output data of each row
while($row = $result1->fetch_assoc()) {
echo '<form class="card" method="post" action="">
<input type="hidden" name="p_id" value="' .$row["pro_id"]. '" />
<a href="product.php?' . $row["pro_id"] . '">
<div class="picontainer">
<img src="'.$row["pro_img"].'" alt="Red Kurta" class="pimage">
<div class="poverlay">' . $row["pro_name"] . ' | ' . $row["price"] .'</div>
<div class="proid" style="display:none">' . $row["pro_id"] . '</div>
</div>
</a>
</form>';
}
}
?>
</div>
</div>
<a class="prev " onclick="pplusSlides(-1) ">❮</a>
<a class="next " onclick="pplusSlides(1) ">❯</a>
</div>
<div class="dot-container ">
<span class="dot " onclick="pcurrentSlide(1) "></span>
<span class="dot " onclick="pcurrentSlide(2) "></span>
</div>
<script>
var pslideIndex = 1;
pshowSlides(pslideIndex);
function pplusSlides(n) {
pshowSlides(pslideIndex += n);
}
function pcurrentSlide(n) {
pshowSlides(pslideIndex = n);
}
function pshowSlides(n) {
var i;
var slides = document.getElementsByClassName("productmySlides ");
var dots = document.getElementsByClassName("dot ");
if (n > slides.length) {
pslideIndex = 1
}
if (n < 1) {
pslideIndex = slides.length
}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none ";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active ", " ");
}
slides[pslideIndex - 1].style.display = "block ";
dots[pslideIndex - 1].className += " active ";
}
</script>
<!-- Script for NotiWindow-->
<script>
// Get the modal
var modal = document.getElementById("NotiWindow");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("Noticlose")[0];
// When the user clicks the button, open the modal
function displayNoti() {
modal.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>
<?php require_once "footer.php"; ?>
</body>
</html>