-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
59 lines (52 loc) · 1.37 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
<?php
require_once('./connection.php');
$sqlQuery = "SELECT * FROM mahasiswa";
$result = $conn->query($sqlQuery);
// if ($result->num_rows > 0) {
// while ($row = $result->fetch_assoc()) {
// echo "ID: " . $row['id'] . ', Nama: ' . $row['nama'] . ', Jenis Kelamin: ' . $row['jenis_kelamin'] . ', Tempat Lahir: ' . $row['tempat_lahir'] . ', Tanggal Lahir: ' . $row['tanggal_lahir'] . ', Alamat: ' . $row['alamat'] . '<br>';
// }
// } else {
// echo "Tidak ada data";
// }
if ($result->num_rows > 0) {
?>
<h1>List Data</h1>
<a href="form-insert.php">Tambah Data</a>
<table border="1">
<tr>
<th>#ID</th>
<th>NIM</th>
<th>Nama</th>
<th>Jenis Kelamin</th>
<th>Tanggal Lahir</th>
<th>Tempat Lahir</th>
<th>Alamat</th>
<th>Aksi</th>
</tr>
<?php
while ($row = $result->fetch_assoc()) {
?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['nim']; ?></td>
<td><?php echo $row['nama']; ?></td>
<td><?php echo $row['jenis_kelamin']; ?></td>
<td><?php echo $row['tanggal_lahir']; ?></td>
<td><?php echo $row['tempat_lahir']; ?></td>
<td><?php echo $row['alamat']; ?></td>
<td>
<a href="form-edit.php?id=<?php echo $row['id']; ?>">Edit</a>
|
<a href="delete.php?id=<?php echo $row['id']; ?>">Hapus</a>
</td>
</tr>
<?php
}
?>
</table>
<?php
} else {
echo "Tidak ada data";
}
?>