<?php
require_once __DIR__ . "/staff_auth.php";
require_once __DIR__ . "/../includes/db.php";

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$conn->set_charset('utf8mb4');

$course_id = (int)($_GET['course_id'] ?? 0);

echo '<option value="">Select an Opti...</option>';
if ($course_id <= 0) exit;

$st = $conn->prepare("
  SELECT id, title
  FROM exams
  WHERE course_id=?
  ORDER BY title
");
$st->bind_param("i", $course_id);
$st->execute();

$rs = $st->get_result();
while($e = $rs->fetch_assoc()){
  echo '<option value="'.(int)$e['id'].'">'.htmlspecialchars($e['title'], ENT_QUOTES, 'UTF-8').'</option>';
}
