-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
158 lines (134 loc) · 5.07 KB
/
Copy pathindex.php
File metadata and controls
158 lines (134 loc) · 5.07 KB
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
151
152
153
154
155
156
157
158
<?php
session_start();
require_once "functions.php";
$data = [];
$price_range = [
1 => [
'min' => 10000,
'max' => 15000
],
2 => [
'min' => 15000,
'max' => 20000,
],
3 => [
'min' => 20000,
'max' => 25000
],
4 => [
'min' => 25000,
'max' => 30000
],
];
if (isset($_GET['price']) && isset($_GET['location'])) {
$res = mysqli_query($conn, 'SELECT * FROM menu WHERE price >= ' . $price_range[$_GET['price']]['min'] . ' AND price < ' . $price_range[$_GET['price']]['max'] . ' AND location = "' . $_GET['location'] . '"');
while ($row = $res->fetch_assoc()) {
$data[] = $row;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>makaNNES</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.5/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<?php require_once "navbar.php" ?>
<div class="jumbotron">
<div class="jumbotron-content">
<div class="container">
<div class="row">
<div class="col-md-6 col-xl-4 mx-auto">
<div class="card">
<div class="card-body">
<h3 class="card-title">Cari menu berdasarkan</h3>
<form action="?" class="search-form">
<div>
<label for="price" class="form-label">Harga</label>
<select class="form-select" name="price" id="price">
<option disabled <?= isset($_GET['price']) ? '' : 'selected' ?>>Pilih harga</option>
<option value="1" <?= isset($_GET['price']) && $_GET['price'] == "1" ? 'selected' : '' ?>>10rb - 15rb</option>
<option value="2" <?= isset($_GET['price']) && $_GET['price'] == "2" ? 'selected' : '' ?>>15rb - 20rb</option>
<option value="3" <?= isset($_GET['price']) && $_GET['price'] == "3" ? 'selected' : '' ?>>20rb - 25rb</option>
<option value="4" <?= isset($_GET['price']) && $_GET['price'] == "4" ? 'selected' : '' ?>>25rb - 30rb</option>
</select>
</div>
<div>
<label for="location" class="form-label">Lokasi</label>
<select class="form-select" name="location" id="location">
<option disabled <?= isset($_GET['location']) ? '' : 'selected' ?>>Pilih lokasi</option>
<option value="banaran" <?= isset($_GET['location']) && $_GET['location'] == "banaran" ? 'selected' : '' ?>>Banaran</option>
<option value="patemon" <?= isset($_GET['location']) && $_GET['location'] == "patemon" ? 'selected' : '' ?>>Patemon</option>
<option value="sekaran" <?= isset($_GET['location']) && $_GET['location'] == "sekaran" ? 'selected' : '' ?>>Sekaran</option>
</select>
</div>
<button type="submit" class="search-btn">
Cari menu relevan
<i class="bi bi-search"></i>
</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php if (count($data) > 0): ?>
<div class="container mt-5 pb-5" id="search">
<div class="row">
<h2 class="text-center mb-3">Menu sesuai pencarian</h2>
<?php foreach ($data as $menu): ?>
<div class="col-md-3">
<div class="card">
<img src="<?= $menu['image'] ?>" class="card-img-top" alt="">
<div class="card-body">
<h5 class="card-title">
<?= $menu['name'] ?>
</h5>
<table class="mb-3">
<tbody>
<tr>
<td>
Harga
</td>
<td class="ps-1">
: Rp. <?= $menu['price'] ?>
</td>
</tr>
<tr>
<td>
Lokasi
</td>
<td class="ps-1">
: <?= $menu['location'] ?>
</td>
</tr>
<tr>
<td>
CP
</td>
<td class="ps-1">
: <?= $menu['contact_person'] ?>
</td>
</tr>
</tbody>
</table>
<a href="<?= $menu['link'] ?>" class="btn btn-pink">
Cek di Maps
</a>
</div>
</div>
</div>
<?php endforeach ?>
</div>
</div>
<?php endif ?>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.5/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>