-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcategories.php
66 lines (50 loc) · 2.41 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
<!-- BOOTSTRAP 5 -->
<!-- <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script> -->
<?php include("partials-front/menu.php"); ?>
<!-- CAtegories Section Starts Here -->
<section class="categories">
<div class="container">
<h2 class="text-center">Explore Foods</h2>
<?php
//Display all active categories from the DB (from tbl_category)
$sql = "SELECT * FROM tbl_category WHERE active='yes'";
//execute the query
$res = mysqli_query($conn, $sql);
//Count the rows of the result set
$count = mysqli_num_rows($res);
//Check wether ther are active categories or not
if ($count > 0) {
//there are active categories
while ($row = mysqli_fetch_assoc($res)) {
$id = $row['id'];
$title = $row['title'];
$image_name = $row['image_name'];
?>
<a href="<?php echo SITE_URL; ?>category-foods.php?category_id=<?php echo $id; ?>">
<div class="box-3 float-container">
<?php
if ($image_name == "") {
//the categpry has no image
echo "<div class='error'>No Image</div>";
} else {
//display the category's image
?>
<img src="<?php echo SITE_URL; ?>images/category/<?php echo $image_name; ?>" alt="<?php echo $image_name ?>" class="img-responsive img-curve" width="283" height="354">
<?php
}
?>
<h3 class="float-text text-white text-center"><?php echo $title; ?></h3>
</div>
</a>
<?php
}
} else {
echo "<div class='error text-center'>No Active Categories</div>";
}
?>
<div class="clearfix"></div>
</div>
</section>
<!-- Categories Section Ends Here -->
<?php include("partials-front/footer.php"); ?>