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

try {
    // Fetch classes ordered by level/name
    $stmt = $pdo->query("SELECT id, class_name FROM classes WHERE status = 1 ORDER BY id ASC");
    $classes = $stmt->fetchAll(PDO::FETCH_ASSOC);

    echo json_encode(['status' => 'success', 'data' => $classes]);
} catch (PDOException $e) {
    echo json_encode(['status' => 'error', 'message' => $e->getMessage()]);
}?>