-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcategory_front.php
61 lines (53 loc) · 2.03 KB
/
category_front.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
<?php
include('front-end/partials/menu.php');
?>
<!-- category section starts -->
<section id="category" class="container">
<div class="heading text-center">
<h1>All <span>Categories</span></h1>
<p>Mouth-watering Food in your Budget!</p>
</div>
<div class="box-container">
<?php
//code to display categories from database
$sql="SELECT * FROM tbl_category WHERE active='YES'";
//execute the query
$res=mysqli_query($conn,$sql);
//count no of rows to check whether there is data in database or not
$count = mysqli_num_rows($res);
//check if there is data in database
if($count>0){
//there is data in database
while($rows=mysqli_fetch_assoc($res)){
$id=$rows['id'];
$title=$rows['title'];
$image_name=$rows['image_name'];
?>
<div class="box">
<?php
if($image_name==''){
?>
<img src="<?php echo SITEURL;?>img.png" alt="">
<?php
}else{
?>
<img src="<?php echo SITEURL;?>images/category/<?php echo $image_name?>" alt="">
<?php
}
?>
<div class="info">
<p><?php echo $title;?></p>
<a href="<?php echo SITEURL;?>category-food.php?id=<?php echo $id?>"><button>view</button></a>
</div>
</div>
<?php
}
}else{
echo "<div class='error'><h1>Category not added</h1></div>";
}?>
</div>
</section>
<!-- category section ends -->
<?php
include('front-end/partials/footer.php');
?>