forked from khrisnairham/pesona-lokal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
43 lines (37 loc) · 1.24 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
<?php
include 'kuliner.php';
// Mengambil kata kunci dari input pencarian
$keyword = $_GET['keyword'];
// Koneksi ke database
$koneksi = mysqli_connect("localhost", "root", "", "pesona_lokal");
// Cek koneksi
if (mysqli_connect_errno()) {
echo "Gagal terhubung ke MySQL: " . mysqli_connect_error();
exit();
}
// Melakukan query pencarian
$query = "SELECT * FROM kuliner WHERE nama_kul LIKE '%$keyword%'";
$result = mysqli_query($koneksi, $query);
// Menampilkan hasil pencarian
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {?>
<!-- // echo "Hasil: " . $row['nama_kul'] . "<br>"; -->
<!-- <div> class="row mb-5 pb-4 pt-5"> -->
<div class="row mb-5 pb-4 pt-5" style="position:relatif;z-index: 99;">
<div class="col-2">
<a href="#"><img src="assets/kuli1.png" alt=""></a>
</div>
<div class="col-3">
<a href="#" class="text-decoration-none text-dark">
<p class="fw-semibold fs-3"><?php echo $row['nama_kul']; ?></p>
</a>
<p class="fs-5 text-dark"><?php echo $row['desk_kul']; ?></p>
</div>
</div>
<?php }
} else {
echo "Tidak ditemukan hasil.";
}
// Menutup koneksi
mysqli_close($koneksi);
?>