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

try {
    $stmt = $pdo->prepare("
        SELECT id, subject_name 
        FROM subjects 
        WHERE status = 1
        ORDER BY subject_name ASC
    ");
    $stmt->execute();

    echo json_encode($stmt->fetchAll(PDO::FETCH_ASSOC));
    exit;
} catch (Exception $e) {
    echo json_encode([]);
    exit;
}
