-
Notifications
You must be signed in to change notification settings - Fork 0
/
categories.php
526 lines (449 loc) · 26.6 KB
/
categories.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
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
<?php
session_start();
include("config.php");
if (isset($_SESSION['mail'])) {
$username = $_SESSION['mail'];
$stmt = $con->prepare("SELECT * FROM cart WHERE Username = ?") or die("Query failed");
$stmt->bind_param("s", $_SESSION['mail']);
$stmt->execute();
$cart_sum = $stmt->get_result();
$Cart_number = $cart_sum->num_rows;
}else{
$Cart_number = 0;
$username = "guest";
}
if (isset($_POST['cat_submit'])) {
$cat_item = mysqli_real_escape_string($con, $_POST['cat_submit']);
$fetch_cat_item = mysqli_query($con, "SELECT * FROM products WHERE Product_category = '$cat_item'") or die("Query failed");
if ($fetch_cat_item->num_rows > 0) {
$cat_results = array();
while ($row = $fetch_cat_item->fetch_assoc()) {
$cat_results[] = array(
'Product_img' => $row['Product_img'],
'Product_name' => $row['Product_name'],
'Price' => $row['Price'],
'Product_category' => $row['Product_category']
);
}
$_SESSION['cate_select'] = $cat_results;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title> Shop || Farmicom</title>
<link rel="apple-touch-icon" sizes="180x180" href="assets/images/favicons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="assets/images/favicons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="assets/images/favicons/favicon-16x16.png">
<link rel="manifest" href="assets/images/favicons/site.webmanifest">
<!-- Fonts-->
<link
href="https://fonts.googleapis.com/css2?family=Barlow:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,300;1,400;1,500;1,600;1,700;1,800&display=swap"
rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Amatic+SC:wght@400;700&display=swap" rel="stylesheet">
<!-- Css-->
<link rel="stylesheet" href="assets/css/animate.min.css">
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/css/owl.carousel.min.css">
<link rel="stylesheet" href="assets/css/owl.theme.default.min.css">
<link rel="stylesheet" href="assets/css/magnific-popup.css">
<link rel="stylesheet" href="assets/css/fontawesome-all.min.css">
<link rel="stylesheet" href="assets/css/swiper.min.css">
<link rel="stylesheet" href="assets/css/bootstrap-select.min.css">
<link rel="stylesheet" href="assets/css/jquery.mCustomScrollbar.min.css">
<link rel="stylesheet" href="assets/css/bootstrap-datepicker.min.css">
<link rel="stylesheet" href="assets/css/vegas.min.css">
<link rel="stylesheet" href="assets/css/nouislider.min.css">
<link rel="stylesheet" href="assets/css/nouislider.pips.css">
<link rel="stylesheet" href="assets/css/agrikol_iconl.css">
<!-- Template styles -->
<link rel="stylesheet" href="assets/css/style.css">
<link rel="stylesheet" href="assets/css/responsive.css">
</head>
<body>
<div class="preloader">
<img src="assets/images/loader.png" class="preloader__image" alt="">
</div><!-- /.preloader -->
<div class="page-wrapper">
<div class="site-header__header-one-wrap">
<div class="topbar-one">
<div class="topbar_bg" style="background-image: url(assets/images/shapes/header-bg.png)"></div>
<div class="container">
<div class="topbar-one__left">
<a href="mail to: info@farmicom.com"><span class="icon-message"></span>info@farmicom.com</a>
<a href="+254 712 345 678"><span class="icon-phone-call"></span>+254 712 345 678</a>
</div>
<div class="topbar-one__middle">
<a href="index.php" class="main-nav__logo">
<img src="assets/images/resources/logo.png" class="main-logo" alt="Awesome Image" />
</a>
</div>
<div class="topbar-one__right">
<div class="topbar-one__social">
<a href="#"><i class="fab fa-facebook-square"></i></a>
<a href="#"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-twitter-x" viewBox="0 0 16 16">
<path d="M12.6.75h2.454l-5.36 6.142L16 15.25h-4.937l-3.867-5.07-4.425 5.07H.316l5.733-6.57L0 .75h5.063l3.495 4.633L12.601.75Zm-.86 13.028h1.36L4.323 2.145H2.865z"/>
</svg></i></a>
<a href="#"><i class="fab fa-instagram"></i></a>
<a href="#"><i class="fab fa-dribbble"></i></a>
</div>
</div>
</div>
</div>
<header class="main-nav__header-one">
<nav class="header-navigation stricky">
<div class="container clearfix">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="main-nav__left">
<a href="#" class="main-nav__search search-popup__toggler"><i
class="icon-magnifying-glass"></i></a>
<a href="#" class="side-menu__toggler">
<i class="fa fa-bars"></i>
</a>
</div>
<div class="main-nav__main-navigation">
<ul class=" main-nav__navigation-box">
<li >
<a href="index.php">Home</a>
</li>
<li class="dropdown current">
<a href="product.php">Shop</a>
<ul>
<li><a href="cart.php">Cart</a></li>
<li><a href="checkout.php">Checkout</a></li>
<li><a href="orders.php">Orders</a></li>
</ul><!-- /.sub-menu -->
</li>
<li class="dropdown">
<a href="about.php">About Us</a>
<ul>
<li><a href="why_choose_us.php">Why Choose Us</a></li>
</ul><!-- /.sub-menu -->
</li>
<li>
<a href="contact.php">Contacts</a>
</li>
<li>
<a href="farmers.php">Farmers</a>
</li>
</ul>
</div><!-- /.navbar-collapse -->
<div class="main-nav__right">
<div class="icon_cart_box">
<?php
if(isset($_SESSION['mail'])){
echo"<div class='usern'>{$_SESSION['mail']}</div>
<center><a href='logout.php'><button class='logout-button'>Logout</button></a></center>";
}else{
echo"<center><a href='lform.php'><button class='logout-button'>Login</button></a></center>";
}
?>
</div>
<div class="icon_cart_box">
<a href="cart.php">
<sup><?php echo $Cart_number?></sup><span class="icon-shopping-cart"></span>
</a>
</div>
</div>
</div>
</nav>
</header>
</div>
<section class="page-header" style="background-image: url(assets/images/backgrounds/page-header-contact.jpg);">
<div class="container">
<h2>Products</h2>
<ul class="thm-breadcrumb list-unstyled">
<li><a href="index.php">Home</a></li>
<li><a href="" class="shop_style">Shop</a></li>
<li><span>Category</span></li>
</ul>
</div>
</section>
<section class="product">
<div class="container">
<div class="row">
<div class="col-xl-3 col-lg-3 col-md-6">
<div class="sidebar-wrapper style2">
<!--Start single sidebar-->
<div class="single-sidebar wow fadeInUp animated" data-wow-delay="0.1s"
data-wow-duration="1200ms">
<div class="sidebar-search-box">
<form class="search-form" action="search.php" method="post">
<input name ="search" type="text" cursor="arrow" readonly>
</form>
</div>
</div>
<!--End single sidebar-->
<!--Start sidebar categories Box-->
<div class="single-sidebar wow fadeInUp animated" data-wow-delay="0.3s"
data-wow-duration="1200ms">
<div class="categories-box">
<div class="title">
<h3>Selected Categories</h3>
</div>
<ul class="categories clearfix">
<?php
if (isset($_SESSION['cate_select'])):
foreach ($_SESSION['cate_select'] as $result):
$productName = $result['Product_category'];
$Select_categories = mysqli_query($con,"SELECT * FROM category WHERE Category = '$productName'") or die("Query failed");
while ($cat_itm = $Select_categories->fetch_assoc()){
?>
<li><a href="#"><?php echo $cat_itm['Category']?></a></li>
<?php } endforeach; endif;?>
<li><a href="product.php"><button class="all_categories">All Categories</button></a></li>
</ul>
</div>
</div>
<!--End sidebar categories Box-->
<!--Start single sidebar-->
<div class="single-sidebar wow fadeInUp animated" data-wow-delay="0.5s"
data-wow-duration="1200ms">
<div class="top_sellers">
<div class="title">
<h3>Latest Products</h3>
</div>
<ul class="top-products">
<?php
$select_products = mysqli_query($con, "SELECT * FROM `products` LIMIT 3") or die('query failed');
if(mysqli_num_rows($select_products) > 0){
while($fetch_products = mysqli_fetch_assoc($select_products)){
?>
<li>
<div class="product_item">
<div class="img-box">
<img src="<?php echo $fetch_products['Product_img'];?>" alt="">
<div class="overlay-content">
<a href="#"><i class="fa fa-link" aria-hidden="true"></i></a>
</div>
</div>
<div class="title-box">
<h4><a href="#">"<?php echo $fetch_products['Product_name'];?>"</a></h4>
<div class="value"> KES "<?php echo $fetch_products['Price'];?>"</div>
</div>
</div>
</li>
<?php } }?>
</ul>
</div>
</div>
<!--End single sidebar-->
</div>
</div>
<!--End Sidebar Wrapper-->
<div class="col-xl-9 col-lg-9">
<div class="product-items">
<div class="all_products">
<div class="row">
<?php
if (isset($_SESSION['cate_select'])):
foreach ($_SESSION['cate_select'] as $result):
?>
<div class="col-xl-4 col-lg-4 col-md-6">
<div class="all_products_single text-center">
<div class="all_product_item_image">
<form id="productForm" action="addToCart.php" method="POST" enctype="multipart/form-data">
<img src="assets/images/shop/cart_product_img-1.jpg" alt="">
<div class="all_product_hover">
<div class="all_product_icon">
<a href="#" id="addToCartLink"><span class="icon-shopping-cart"> </span></a>
</div>
</div>
</div>
<h4><?php echo $result['Product_name']; ?></h4>
<p><?php echo $result['Price']; ?></p>
<input type="hidden" name="product_name" value="<?php echo $result['Product_name']; ?>">
<input type="hidden" name="price" value="<?php echo $result['Price']; ?>">
<input type="hidden" name="product_image" value="<?php echo $result['Product_img']; ?>">
</form>
</div>
</div>
<?php endforeach; ?>
<?php else: ?>
<p>No items under this category yet</p>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<footer class="site-footer">
<div class="site-footer_farm_image"><img src="assets/images/resources/site-footer-farm.png"
alt="Farm Image"></div>
<div class="container">
<div class="row no-gutters">
<div class="col-xl-4 col-lg-4 col-md-6">
<div class="footer-widget__column footer-widget__about wow fadeInUp" data-wow-delay="100ms">
<div class="footer-widget__title">
<h3>About</h3>
</div>
<div class="footer-widget_about_text">
<p>Experience elevated farming with Farmicom : where seamless online shopping, top-quality products,
and innovative solutions converge </p>
</div>
<?php
if(isset($_POST['subscribe'])){
$Email = mysqli_real_escape_string($con, $_POST['email']);
$stmt = $con->prepare("SELECT * FROM subscriptions WHERE Email = ?");
$stmt -> bind_param("s",$Email);
$stmt -> execute();
$fetch_sub = $stmt -> get_result();
if($fetch_sub->num_rows!==0){
echo "<script>alert('Already subscribed');</script>";
}else{
mysqli_query($con, "INSERT INTO subscriptions (email) VALUES('$Email')");
echo "<script>alert('Subscribed successfully');</script>";
}
}
?>
<form action="" method="post">
<div class="footer_input-box">
<input type="Email" name = "email" placeholder="Email Address">
<button type="submit" name="subscribe" class="button"><i class="fa fa-check"></i></button>
</div>
</form>
</div>
</div>
<div class="col-xl-2 col-lg-2 col-md-6">
<div class="footer-widget__column footer-widget__link wow fadeInUp" data-wow-delay="200ms">
<div class="footer-widget__title">
<h3>Explore</h3>
</div>
<ul class="footer-widget__links-list list-unstyled">
<li><a href="about.php">About Us</a></li>
<li><a href="product.php">Shop with us</a></li>
<li><a href="farmers.php">Meet the Farmers</a></li>
<li><a href="contact.php">Contact</a></li>
</ul>
</div>
</div>
<div class="col-xl-3 col-lg-3 col-md-6">
<div class="footer-widget__column footer-widget__contact wow fadeInUp" data-wow-delay="400ms">
<div class="footer-widget__title">
<h3>Contact</h3>
</div>
<div class="footer-widget_contact">
<p>Nairobi, Kenya<br>365-00100, Nairobi</p>
<a href="mailto:info@farmicom.com">info@farmicom.com</a><br>
<a href="tel:+254 712 345 678">+254 712 345 678</a>
<div class="site-footer__social">
<a href="#"><i class="fab fa-facebook-square"></i></a>
<a href="#"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-twitter-x" viewBox="0 0 16 16">
<path d="M12.6.75h2.454l-5.36 6.142L16 15.25h-4.937l-3.867-5.07-4.425 5.07H.316l5.733-6.57L0 .75h5.063l3.495 4.633L12.601.75Zm-.86 13.028h1.36L4.323 2.145H2.865z"/>
</svg></i></a>
<a href="#"><i class="fab fa-instagram"></i></a>
<a href="#"><i class="fab fa-dribbble"></i></a>
</div>
</div>
</div>
</div>
</div>
</div>
</footer>
<div class="site-footer_bottom">
<div class="container">
<div class="site-footer_bottom_copyright">
<p>@ All copyright 2024, <a href="#">Farmicom.com</a></p>
</div>
<div class="site-footer_bottom_menu">
<ul class="list-unstyled">
<li><a href="#">Privacy Policy</a></li>
<li><a href="#">Terms of Use</a></li>
</ul>
</div>
</div>
</div>
</div><!-- /.page-wrapper -->
<a href="#" data-target="html" class="scroll-to-target scroll-to-top"><i class="fa fa-angle-up"></i></a>
<div class="side-menu__block">
<div class="side-menu__block-overlay custom-cursor__overlay">
<div class="cursor"></div>
<div class="cursor-follower"></div>
</div><!-- /.side-menu__block-overlay -->
<div class="side-menu__block-inner ">
<div class="side-menu__top justify-content-end">
<a href="#" class="side-menu__toggler side-menu__close-btn"><img
src="assets/images/shapes/close-1-1.png" alt=""></a>
</div><!-- /.side-menu__top -->
<nav class="mobile-nav__container">
<!-- content is loading via js -->
</nav>
<div class="side-menu__sep"></div><!-- /.side-menu__sep -->
<div class="side-menu__content">
<p><a href="mailto:info@farmicom.com">info@farmicom.com</a> <br> <a href="tel:254-712-3456">+254 712 345
678</a></p>
<div class="side-menu__social">
<a href="#"><i class="fab fa-facebook-square"></i></a>
<a href="#"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-twitter-x" viewBox="0 0 16 16">
<path d="M12.6.75h2.454l-5.36 6.142L16 15.25h-4.937l-3.867-5.07-4.425 5.07H.316l5.733-6.57L0 .75h5.063l3.495 4.633L12.601.75Zm-.86 13.028h1.36L4.323 2.145H2.865z"/>
</svg></i></a>
<a href="#"><i class="fab fa-instagram"></i></a>
<a href="#"><i class="fab fa-pinterest-p"></i></a>
</div>
</div><!-- /.side-menu__content -->
</div><!-- /.side-menu__block-inner -->
</div><!-- /.side-menu__block -->
< <div class="search-popup">
<div class="search-popup__overlay custom-cursor__overlay">
<div class="cursor"></div>
<div class="cursor-follower"></div>
</div><!-- /.search-popup__overlay -->
<div class="search-popup__inner">
<form action="search.php" class="search-popup__form" method="post">
<input type="text" name="search" placeholder="Type here to Search....">
<button name= "btnt" type="submit"><i class="fa fa-search"></i></button>
</form>
</div>
</div>
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/owl.carousel.min.js"></script>
<script src="assets/js/waypoints.min.js"></script>
<script src="assets/js/jquery.counterup.min.js"></script>
<script src="assets/js/TweenMax.min.js"></script>
<script src="assets/js/wow.js"></script>
<script src="assets/js/jquery.magnific-popup.min.js"></script>
<script src="assets/js/jquery.ajaxchimp.min.js"></script>
<script src="assets/js/swiper.min.js"></script>
<script src="assets/js/typed-2.0.11.js"></script>
<script src="assets/js/vegas.min.js"></script>
<script src="assets/js/jquery.validate.min.js"></script>
<script src="assets/js/bootstrap-select.min.js"></script>
<script src="assets/js/countdown.min.js"></script>
<script src="assets/js/jquery.mCustomScrollbar.concat.min.js"></script>
<script src="assets/js/bootstrap-datepicker.min.js"></script>
<script src="assets/js/nouislider.min.js"></script>
<script src="assets/js/isotope.js"></script>
<script src="assets/js/appear.js"></script>
<script src="assets/js/jquery-ui.js"></script>
<script>
$(document).ready(function() {
$(document).on('click', '#addToCartLink', function(e) {
e.preventDefault(); // Prevent the default link behavior
var form = $(this).closest('form'); // Get the closest form element
var formData = form.serialize(); // Serialize the form data
$.ajax({
type: 'POST',
url: 'addToCart.php',
data: formData,
success: function(response) {
window.location.href = window.location.href;
alert(response);
},
error: function() {
alert('An error occurred while adding the product to the cart.');
}
});
});
});
</script>
<!-- template scripts -->
<script src="assets/js/theme.js"></script>
</body>
</html>