<?php
require_once __DIR__ . "/../../../app/config/koneksi.php";

header("Content-Type: application/json; charset=UTF-8");

$sql = mysqli_query($koneksi,
    "SELECT nama_kegiatan, tanggal, deskripsi, foto
     FROM kegiatan
     WHERE status_event = 1
     ORDER BY tanggal ASC"
);

$data = [];
while ($row = mysqli_fetch_assoc($sql)) {
    $data[] = [
        "nama" => $row['nama_kegiatan'],
        "tanggal" => $row['tanggal'],
        "deskripsi" => $row['deskripsi'],
        "foto" => base_url('/assets/img/kegiatan/' . $row['foto'])
    ];
}

echo json_encode($data);
