-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfood-search.php
68 lines (60 loc) · 2.37 KB
/
food-search.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
<?php
include('front-end/partials/menu.php');
?>
<!-- dishes section starts -->
<section id="dishes" class="container-fluid">
<div class="heading text-center">
<?php
$search=$_POST['search'];
?>
<h1>Results for <span><?php echo $search;?></span></h1>
<p>Beyond the boundaries of taste</p>
<p>Hurry!! Order now!</p>
</div>
<div class="card-container">
<?php
$sql="SELECT * FROM tbl_dishes WHERE title LIKE '%$search%' OR description LIKE '%$search%'";
//execute the query
$res=mysqli_query($conn,$sql);
//count no of rows to check whether there is data in database or not
// $res = mysqli_query($conn, $sql) or trigger_error("Query Failed! SQL: $sql - Error: ".mysqli_error($conn), E_USER_ERROR);
$count = mysqli_num_rows($res);
if($count>0){
//there is data in database
while($rows=mysqli_fetch_assoc($res)){
$id_dish=$rows['id'];
$title_dish=$rows['title'];
$image_name_dish=$rows['image_name'];
$description=$rows['description'];
$price=$rows['price'];
?>
<!-- display foods-->
<div class="card">
<?php
if($image_name_dish==''){
?>
<img src="<?php echo SITEURL;?>img.png" alt="">
<?php
}else{
?>
<img src="<?php echo SITEURL;?>images/food/<?php echo $image_name_dish;?>" alt="">
<?php
}
?>
<h2><?php echo $title_dish;?></h2>
<h4>Price: Rs.<?php echo $price;?>/-</h4>
<p><?php echo $description;?></p>
<a href="<?php echo SITEURL;?>order.php"><button>order now</button></a>
</div>
<?php
}
}else{
echo "<div class='error'><h1>Sorry, there are no matching result for $search.<br><br>1. Try more general words.<br>2. Try different words with similar meaning<br>3. Please check your spelling</h1></div>";
}
?>
</div>
</section>
<!-- dishes section ends -->
<?php
include('front-end/partials/footer.php');
?>