-
Notifications
You must be signed in to change notification settings - Fork 3
/
search.php
150 lines (127 loc) · 4.33 KB
/
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
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
<?php
session_start();
include('dbconnect.php');
$cusID = $_SESSION['cusID'];
$foodID = $_REQUEST['foodID'];
$foodkey = "%".$foodID.'%';
$query = "SELECT available_foods.resID as resID, food.foodID as foodID, food.foodName as foodName, food.price as price
FROM available_foods INNER JOIN food
ON available_foods.foodID = food.foodID
WHERE available_foods.foodID IN (SELECT foodID FROM food WHERE foodname LIKE '$foodkey' or foodType LIKE '$foodkey') ";
$result = mysqli_query($connection, $query);
$foods = mysqli_fetch_all($result, MYSQLI_ASSOC);
if (isset($_GET['message'])) {
$message = $_GET['message'];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title><?php echo "Search of ".$foodID; ?></title>
</head>
<body>
<!-- Add your restaurant content here -->
<div class="restaurant-menu" id="restaurant1-menu">
<h1>Searched Items</h1>
<div class="menu-content">
<main>
<div class="menu-items">
<!-- Menu Items -->
<?php foreach($foods as $food): ?>
<?php
$resID = $food['resID'];
$res = "SELECT name FROM restaurant WHERE resID='$resID'";
$res = mysqli_query($connection, $res);
$res = mysqli_fetch_all($res, MYSQLI_ASSOC);
?>
<div class="menu-item" data-id="<?php echo $food['foodID']; ?>" data-available-quantity="3">
<img class="menu-img" src="resources/<?php echo $food['foodID'];?>.png">
<div class="menu-desc">
<h4><?php echo $food['foodName']; ?></h4>
<p><?php echo $res[0]['name']; ?></p>
<p>৳<?php echo $food['price']; ?></p>
<div class="cart-controls">
<form action="add-to-cart.php" method="post" class="add-to-cart-form">
<input type="hidden" name="cusID" value="<?php echo $cusID; ?>">
<input type="hidden" name="resID" value="<?php echo $resID; ?>">
<input type="hidden" name="foodID" class="food-id" value="<?php echo $food['foodID']; ?>">
<input type="hidden" name="price" class="food-price" value="<?php echo $food['price']; ?>">
<input type="number" name="quantity" class="food-quantity" value="0">
<input type="submit" class="add-to-cart-btn" name="Add to Cart">
</form>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<button class="cartbutton" onclick="window.location.href='cart.php'">Go to Cart</button>
</div>
</main>
<style>
.cartbutton{
margin: 0 auto;
margin-top: 30px;
background-color: white;
color: #87CEEB;
padding: 7px 9px;
border: none;
cursor: pointer;
width: 20%;
}
.restaurant-menu {
text-align: center;
margin:50px;
width:100% ;
display: grid;
padding: 5%;
border-radius: 8px;
gap: 1.5rpm;
overflow: hidden;
}
.menu-items {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 20px;
margin-top: 30px;
cursor: pointer;
}
.menu-item {
background-color: #f5f5f5;
border-radius: 10px;
padding: 20px;
text-align: center;
}
.menu-img {
max-width: 100%;
border-radius: 20px;
width: 150px;
height: 150px;
}
.menu-desc {
margin-top: 10px;
}
#restaurant1-menu ,#restaurant2-menu{
background-color: var(--secondaryColor);
border: #222;
}
.restaurant1-menu:hover ,.restaurant2-menu:hover{
background-color: var(--primaryColor);
color: var(--whiteColor);
}
</style>
<script>
function displayAlert(message) {
alert(message);
}
<?php if (isset($_GET['message'])): ?>
displayAlert("<?php echo $message; ?>");
<?php endif; ?>
</script>
</body>
</html>