<?php
session_start();

$pdo = new PDO("mysql:host=localhost;dbname=kaltekgo_avila", "kaltekgo_admin", "kaltek@2024");
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$id_turma = $_GET['id_turma'];
$id_professor = $_SESSION['idProfessor'];

$sql = "SELECT DISTINCT id_disciplina, nomeDisciplina
FROM disciplinaProfessor
WHERE id_turma = :id_turma
  AND id_professor = :id_professor
ORDER BY nomeDisciplina ASC";

$stmt = $pdo->prepare($sql);
$stmt->execute([
    ':id_turma' => $id_turma,
    ':id_professor' => $id_professor
]);

$disciplinas = $stmt->fetchAll();

foreach ($disciplinas as $disc) {
    echo "<option value='{$disc['id_disciplina']}' data-nome='{$disc['nomeDisciplina']}'>{$disc['nomeDisciplina']}</option>";
}
