<?php

require_once "conn.php";

$stmt = $conn->prepare("SELECT id, gambar, nama, tgl_upload FROM gambar_gallery;");

$stmt->execute();
$stmt->bind_result($id, $gambar, $nama, $tgl_upload);

$galeri = array();

while($stmt->fetch()){
    $temp = array();
    $temp['id'] = $id;
    $temp['gambar'] = $gambar;
    $temp['nama'] = $nama;
    $temp['tgl_upload'] = $tgl_upload;
    

    array_push($galeri, $temp);
}

echo json_encode($galeri);