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

// --- 1. INCLUDE DATABASE CONNECTION ---
// This file provides the $conn (MySQLi) and $pdo (PDO) objects
require_once 'db_connect.php';


$response = [];

// --- Fetch the latest popup banner ---
$sql = "SELECT image_url FROM popup_banners ORDER BY id DESC LIMIT 1";
$result = $conn->query($sql);

if ($result && $result->num_rows > 0) {
    $row = $result->fetch_assoc();
    $response['imageUrl'] = $row['image_url'];
} else {
    $response['imageUrl'] = null; // Or a default image
}

echo json_encode($response);

$conn->close();
?>