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

try {
    $stmt = $pdo->query("SELECT id, class_name FROM classes ORDER BY id ASC");
    $classes = $stmt->fetchAll(PDO::FETCH_ASSOC);
    echo json_encode($classes);
} catch (Exception $e) {
    echo json_encode([]);
}