<?php
include 'conexao.php';

$turma_id = $_GET['turma_id'] ?? null;

if ($turma_id) {
    $stmt = $conn->prepare("SELECT nome FROM alunos WHERE turma_id = ? ORDER BY nome");
    $stmt->bind_param("i", $turma_id);
    $stmt->execute();
    $res = $stmt->get_result();
    
    $alunos = [];
    while ($row = $res->fetch_assoc()) {
        $alunos[] = $row;
    }

    echo json_encode($alunos);
}
?>
