<?php

require 'conexion.php';

$data = array();

$query = "SELECT title, image_url FROM carousel_images";

$stmt = $connect->prepare($query);
$stmt->execute();
$result = $stmt->get_result();

if ($result && $result->num_rows > 0) {
    while ($row = $result->fetch_assoc()) {
        // Adding only image_url to the $data array
        $data[] = $row;
    }
    // Returning the image_url array as JSON
    echo json_encode($data);
} else {
    echo json_encode(array('message' => 'No data found'));
}
