<?php
require_once '../koneksi.php';

$id_rombel = $_GET['id_rombel'] ?? 0;
// PASTIKAN NAMA TABELNYA SAMA: jadwal_waktu_rombels
$q = mysqli_query($koneksi, "SELECT * FROM jadwal_waktu_rombels WHERE id_rombel = '$id_rombel' ORDER BY waktu_mulai ASC");

if (!$q) {
    echo "<option>Error Database</option>";
    exit;
}

if (mysqli_num_rows($q) == 0) {
    echo "<option>Jam belum diatur untuk kelas ini!</option>";
} else {
    echo "<option value=''>-- Pilih Jam --</option>";
    while($j = mysqli_fetch_array($q)) {
        if($j['is_istirahat'] == 0) {
            $val = $j['waktu_mulai'] . '|' . $j['waktu_selesai'];
            echo "<option value='{$val}'>{$j['nama_jam']} ({$j['waktu_mulai']} - {$j['waktu_selesai']})</option>";
        }
    }
}
?>