<?php

// Aktifkan error reporting untuk debugging
ini_set('display_errors', 1);
ini_set('log_errors', 1);
ini_set('error_log', __DIR__ . '/error.log');
error_reporting(E_ALL);

include '../includes/auth.php';
include '../includes/functions.php';

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

$id_event = (int)$_GET['id_event'] ?? 0;

$query = "SELECT * FROM dafdir_event_foto WHERE id_event = ? ORDER BY urutan, created_at";
$stmt = $conn->prepare($query);
$stmt->bind_param("i", $id_event);
$stmt->execute();
$result = $stmt->get_result();

$fotos = [];
while ($row = $result->fetch_assoc()) {
    $fotos[] = $row;
}

echo json_encode($fotos);
?>