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

$query = mysqli_query($con,"SELECT * FROM guru");
?>
<?php require 'header.php';?>

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

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

    <table class="table table-bordered table-striped">
        <thead>
            <tr>
                <th>ID</th>
                <th>Nama</th>
                <th>NIP</th>
                <th>Username</th>
                <th>No HP</th>
                <th>Aksi</th>
            </tr>
        </thead>

        <tbody>
        <?php while($data = mysqli_fetch_assoc($query)) { ?>
            <tr>
                <td><?= $data['id_guru']; ?></td>
                <td><?= $data['nama']; ?></td>
                <td><?= $data['nip']; ?></td>
                <td><?= $data['username']; ?></td>
                <td><?= $data['no_hp']; ?></td>
                <td>
                    <a href="edit_guru.php?id=<?= $data['id_guru']; ?>" class="btn btn-warning btn-sm">
                        Edit
                    </a>

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

    </table>
</div>

<?php include 'footer.php';?>