-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcari_resep.php
83 lines (79 loc) · 2.65 KB
/
cari_resep.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
<?php
include 'includes/connect.php';
?>
<!DOCTYPE html>
<html>
<title></title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/jquery.mobile-1.4.5.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<?php include('nav.html'); ?>
<?php
if (isset($_GET['bahan'])) {
$sql = "SELECT data_resep.*
,data_bahan.id_resep
,GROUP_CONCAT(data_bahan.nama_bahan) AS bahan
FROM data_bahan
LEFT JOIN data_resep ON data_bahan.id_resep = data_resep.id_resep
GROUP BY data_bahan.id_resep
HAVING ";
$x = 1;
foreach($_GET['bahan'] as $bahan) {
$sql = $sql . "bahan LIKE '%" . $bahan . "%'";
if ($x != count($_GET['bahan'])) {
$sql = $sql . ' AND ';
}
$x++;
}
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result)>0) {
echo '<div data-role="page" class="ui-body ui-body-a ui-corner-all">';
echo '<div class="container" data-role="main" class="ui-content">';
echo '<h1 style="text-align: center;">Hasil Pencarian</h1>';
echo '<br/>';
echo '<div class="table-responsive">';
echo '<table class="table table-striped">';
echo '<thead>';
echo '<tr>';
echo '<th class="info">No</th>';
echo '<th class="info">Nama Masakan</th>';
echo '<th class="info">Deskripsi</th>';
echo '<th class="info">Lihat Resep</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
$x = 1;
while ($row = mysqli_fetch_assoc($result)) {
echo '<tr>';
echo "<td>".$x." : </td>";
echo "<td>" . $row['nama_resep']."</td>";
echo "<td>" . $row['deskripsi_resep']."</td>";
echo "<td><a href='lihat_resep.php?id=" . $row['id_resep']."'>Lihat Resep</a></td>";
echo '</tr>';
$x++;
}
echo '</tbody>';
echo '</table>';
echo '</div>';
echo '</div>';
echo '</div>';
}
else {
echo "Bahan yang anda masukan tidak ada yang cocok";
}
}
else {
echo "Masukan Bahan terlebih dahulu";
}
?>
<!-- jQuery library -->
<script src="js/jquery-3.1.1.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="js/bootstrap.min.js"></script>
<!-- Include the jQuery Mobile library -->
<script src="js/jquery.mobile-1.4.5.min.js"></script>
</body>
</html>