<?php
require("../../includes/config.php");
header("Content-Type: application/json");

try {
    // Fetch all sessions except perhaps the current one, or all of them
    $stmt = $pdo->query("SELECT id, year_name, is_current FROM academic_years ORDER BY id DESC");
    $years = $stmt->fetchAll(PDO::FETCH_ASSOC);
    echo json_encode($years);
} catch (PDOException $e) {
    echo json_encode([]);
}?>