<?php
require 'db_config.php';

header('Content-Type: application/json');

$sql = "SELECT * FROM notifications WHERE read_status = 0 ORDER BY created_at DESC";
$result = $conn->query($sql);

$notifications = [];

if ($result && $result->num_rows > 0) {
    while ($row = $result->fetch_assoc()) {
        $notifications[] = $row;
    }
}

echo json_encode($notifications);
?>
