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

$now = date("Y-m-d");
$future = date("Y-m-d", strtotime("+7 days"));

$sql = $koneksi->prepare("
    SELECT id, nama_kegiatan, tanggal, deskripsi, foto
    FROM kegiatan
    WHERE tanggal >= ? AND tanggal <= ?
    ORDER BY tanggal ASC
");
$sql->bind_param("ss", $now, $future);
$sql->execute();

$result = $sql->get_result();
$data = [];

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

echo json_encode($data);
