<?php
require 'db_connect.php'; // Make sure you have a file to handle your DB connection

$sql = "SELECT id, title, message, image_url, created_at FROM notifications ORDER BY created_at DESC";
$result = $conn->query($sql);

$notifications = array();

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

header('Content-Type: application/json');
echo json_encode($notifications);

$conn->close();
?>