<?php
header("Content-Type: application/json");

require("../includes/config.php");


try {
    $stmt = $pdo->query("SELECT id, class_name,  status, session_year,class_section FROM classes ORDER BY id DESC");
    $classes = $stmt->fetchAll();

    echo json_encode([
        "status" => "success",
        "data" => $classes
    ]);
} catch (Exception $e) {
    echo json_encode([
        "status" => "error",
        "message" => "Failed to load classes"
    ]);
}
?>
