<?php
include('config.php');

if ($conn->connect_error) die("Connection failed");

$class = $_GET['class'];
$terms = [];

$sql = $conn->prepare("SELECT DISTINCT term FROM end_term_report WHERE classes = ?");
$sql->bind_param("s", $class);
$sql->execute();
$result = $sql->get_result();

while($row = $result->fetch_assoc()) {
    $terms[] = $row['term'];
}

echo json_encode($terms);
