-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
111 lines (97 loc) · 3.11 KB
/
index.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
<?php
$connection = mysqli_connect("localhost", "admin", "adminoke", "tokobuah");
if($warna = $_GET['warna']){
$select = mysqli_query($connection, "SELECT * FROM buah WHERE warna = '$warna'");
}
else{
$select = mysqli_query($connection, "SELECT * FROM buah");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form action="" method="GET">
<select name="warna">
<option value="">Pilih warna</option>
<option value="merah">Merah</option>
<option value="kuning">Kuning</option>
<option value="hijau">Hijau</option>
</select>
<button>cari</button>
</form>
<br />
<table border="1" style="border-collapse: collapse" cellpadding="5px">
<thead>
<th>ID</th>
<th>Nama buah</th>
<th>Warna</th>
<th>Rasa</th>
<th>Action</th>
</thead>
<tbody>
<?php while($row = mysqli_fetch_assoc($select)) : ?>
<tr>
<td><?php echo $row['id'] ?></td>
<td><?php echo $row['nama'] ?></td>
<td><?php echo $row['warna'] ?></td>
<td><?php echo $row['rasa'] ?></td>
<td>
<a href="edit.php?id=<?php echo $row['id'] ?>">
<button>Edit</button>
</a>
<a href="delete.php?id=<?php echo $row['id'] ?>">
<button>Delete</button>
</a>
</td>
</tr>
<?php endwhile ?>
</tbody>
</table>
<br>
<form action="create_process.php" method="POST">
<fieldset>
<legend>Form data buah</legend>
<table>
<tr>
<td>Nama buah</td>
<td>:</td>
<td>
<input type="text" name="nama" />
</td>
</tr>
<tr>
<td>Warna buah</td>
<td>:</td>
<td>
<select name="warna">
<option value="">Pilih warna</option>
<option value="merah">Merah</option>
<option value="kuning">Kuning</option>
<option value="hijau">Hijau</option>
</select>
</td>
</tr>
<tr>
<td>Rasa buah</td>
<td>:</td>
<td>
<input type="text" name="rasa" />
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<button>Simpan</button>
</td>
</tr>
</table>
</fieldset>
</form>
</body>
</html>