<?php
include 'includes/conn.php';

if (isset($_GET['class_id'])) {
    $class_id = $_GET['class_id'];

    $stmt = $pdo->prepare("
        SELECT s.id, s.code, s.name
        FROM subjects s
        JOIN class_subjects cs ON s.id = cs.subject_id
        WHERE cs.classroom_id = ?
        ORDER BY s.name
    ");
    $stmt->execute([$class_id]);
    $subjects = $stmt->fetchAll(PDO::FETCH_ASSOC);

    foreach ($subjects as $subject) {
        echo "<option value='{$subject['id']}'>{$subject['code']} - {$subject['name']}</option>";
    }
}
?>
