<?php
require 'koneksi.php';
$con = open_connection();

$query = mysqli_query($con, "SELECT * FROM murid");
?>

<?php require "header.php"; ?>

<div class="container mt-4">
    <h2>Data Murid</h2>

    <a href="tambah_murid.php" class="btn btn-primary mb-3">
        Tambah Murid
    </a>

    <table class="table table-bordered table-striped">
        <thead>
            <tr>
                <th>ID</th>
                <th>Nama</th>
                <th>NISN</th>
                <th>Kode Kelas</th>
                <th>Aksi</th>
            </tr>
        </thead>

        <tbody>
        <?php while($data = mysqli_fetch_assoc($query)) { ?>
            <tr>
                <td><?= $data['id_murid']; ?></td>
                <td><?= $data['nama']; ?></td>
                <td><?= $data['nisn']; ?></td>
                <td><?= $data['kode_kelas']; ?></td>
                <td>
                    <a href="edit_murid.php?id=<?= $data['id_murid']; ?>" class="btn btn-warning btn-sm">Edit</a>

                    <a href="hapus_murid.php?id=<?= $data['id_murid']; ?>"
            class="btn btn-danger btn-sm"
            onclick="return confirm('Yakin hapus data?')">
            Hapus
                    </a>
                </td>
            </tr>
        <?php } ?>
        </tbody>
    </table>
</div>
<?php include 'footer.php';?>