Files
D1041231014_ProvertyMapping/01/api/read_histori_bantuan.php
T
2026-06-07 19:10:40 +07:00

26 lines
587 B
PHP

<?php
include "db_config.php";
header('Content-Type: application/json');
$kemiskinan_id = intval($_GET['kemiskinan_id'] ?? 0);
if ($kemiskinan_id <= 0) {
echo json_encode(["status" => "error", "message" => "kemiskinan_id tidak valid"]);
exit;
}
$sql = "SELECT * FROM histori_bantuan WHERE kemiskinan_id=$kemiskinan_id ORDER BY tanggal DESC";
$result = $conn->query($sql);
if (!$result) {
echo json_encode(["status" => "error", "message" => $conn->error]);
exit;
}
$data = [];
while ($row = $result->fetch_assoc()) {
$data[] = $row;
}
echo json_encode($data);
?>