-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.php
67 lines (63 loc) · 2.46 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
<!-- Panggil file koneksi, karena kita membutuhkan nya -->
<?php
include "koneksi.php"
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Halaman Utama</title>
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
</head>
<body>
<section class="row">
<div class="col-md-6 offset-md-3 align-self-center">
<h1 class="text-center">Daftar Siswa</h1>
<a href="tambah.php" class="btn btn-primary mb-2">Tambah</a>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th scope="col">No</th>
<th scope="col">Nis</th>
<th scope="col">Nama</th>
<th scope="col">Kelas</th>
<th scope="col">Aksi</th>
</tr>
</thead>
<?php
// variable no digunakan untuk meng-increments field no pada table. Karena nanti kita akan melooping data hasil query select kita.
$no = 1;
// Simpan query kita kedalam variable agar lebih rapi, dan bisa reusable.
// Arti dari query di bawah adalah pilih semua data dari table tb_siswa.
$query = "SELECT * FROM tb_siswa";
// Eksekusi Query
// Simpan hasil eksekusi query kita ke dalam variable. Di sini variable nya saya kasih nama result.
$result = mysqli_query($koneksi, $query);
// Done. Waktunya Looping
?>
<tbody>
<?php
foreach ($result as $data){
echo "
<tr>
<th scope='row'>". $no++ ."</th>
<td>". $data["nis"] ."</td>
<td>". $data["nama"] ."</td>
<td>". $data["kelas"] ."</td>
<td>
<a href='update.php?id=".$data["id"]."' type='button' class='btn btn-success'>Update</a>
<a href='delete.php?id=".$data["id"]."' type='button' class='btn btn-danger' onlick='return confirm('Yakin ingin menghapus data?')'>Delete</a>
</td>
</tr>
";
}
?>
</tbody>
</table>
</div>
</section>
</body>
</html>