<?php
include "../koneksi.php";

$id = $_GET['id'];

// cek apakah kelas dipakai santri
$cek = mysqli_query($conn, "SELECT * FROM santri WHERE id_kelas='$id'");
if (mysqli_num_rows($cek) > 0) {
    die("Kelas tidak bisa dihapus karena masih dipakai santri");
}

mysqli_query($conn, "DELETE FROM kelas WHERE id_kelas='$id'");
header("Location: kelas.php");
exit;
