<?php
include 'db_connection.php';

try {
    $stmt = $pdo->prepare("SELECT id, name FROM subjects");
    $stmt->execute();
    $data = $stmt->fetchAll(PDO::FETCH_ASSOC);

    echo json_encode($data);
} catch (PDOException $e) {
    echo json_encode(['success' => false, 'message' => 'Error fetching subjects: ' . $e->getMessage()]);
}
?>
