-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathview_categories.php
64 lines (63 loc) · 2.55 KB
/
view_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
<?php
$title = "All Product Categories";
$sub_title = "";
if(isset($_GET['c']) && isset($_GET['s'])){
$cat_qry = $conn->query("SELECT * FROM categories where md5(id) = '{$_GET['c']}'");
if($cat_qry->num_rows > 0){
$title = $cat_qry->fetch_assoc()['category'];
}
$sub_cat_qry = $conn->query("SELECT * FROM sub_categories where md5(id) = '{$_GET['s']}'");
if($sub_cat_qry->num_rows > 0){
$sub_title = $sub_cat_qry->fetch_assoc()['sub_category'];
}
}
elseif(isset($_GET['c'])){
$cat_qry = $conn->query("SELECT * FROM categories where md5(id) = '{$_GET['c']}'");
if($cat_qry->num_rows > 0){
$title = $cat_qry->fetch_assoc()['category'];
}
}
elseif(isset($_GET['s'])){
$sub_cat_qry = $conn->query("SELECT * FROM sub_categories where md5(id) = '{$_GET['s']}'");
if($sub_cat_qry->num_rows > 0){
$title = $sub_cat_qry->fetch_assoc()['sub_category'];
}
}
?>
<!-- Header-->
<header class="bg-dark py-5" id="main-header">
<div class="container px-4 px-lg-5 my-5">
<div class="text-center text-white">
<h1 class="display-4 fw-bolder"><?php echo $title ?></h1>
<p class="lead fw-normal text-white-50 mb-0"><?php echo $sub_title ?></p>
</div>
</div>
</header>
<!-- Section-->
<section class="py-5">
<div class="container px-4 px-lg-5 mt-5">
<div class="row gx-2 gx-lg-5 row-cols-1 row-cols-md-2 row-cols-xl-2 justify-content-center">
<?php
$whereData = "";
$categories = $conn->query("SELECT * FROM `categories` where status = 1 order by category asc ");
while($row = $categories->fetch_assoc()):
foreach($row as $k=> $v){
$row[$k] = trim(stripslashes($v));
}
$row['description'] = strip_tags(stripslashes(html_entity_decode($row['description'])));
?>
<div class="col mb-6 mb-2">
<a href="./?p=products&c=<?php echo md5($row['id']) ?>" class="card category-item text-decoration-none text-reset">
<div class="card-body p-4">
<div class="">
<!-- Product name-->
<h5 class="fw-bolder border-bottom border-pink"><?php echo $row['category'] ?></h5>
</div>
<p class="m-0 truncate"><?php echo $row['description'] ?></p>
</div>
</a>
</div>
<?php endwhile; ?>
</div>
</div>
</section>