<?php
include 'koneksi.php';
session_start();
if (!isset($_SESSION['login_admin'])) {
    header('Location: dashboard.php');
    exit;
}

if (isset($_GET['id'])) {
    $id_ruang = intval($_GET['id']);

    // Delete the record
    $delete_query = "DELETE FROM tb_ruang WHERE id_ruang = $id_ruang";
    if (mysqli_query($host, $delete_query)) {
        echo "<script>alert('Ruang kelas berhasil dihapus!'); window.location.href='manage_ruangkelas.php';</script>";
    } else {
        echo "<script>alert('Error: " . mysqli_error($host) . "'); window.location.href='manage_ruangkelas.php';</script>";
    }
} else {
    header('Location: manage_ruangkelas.php');
    exit;
}
?>

