24 lines
678 B
PHP
24 lines
678 B
PHP
<?php
|
|
header('Content-Type: application/json');
|
|
include 'db_config.php';
|
|
|
|
$sql = 'SELECT id, kategori, pelapor_nama, kontak_pelapor, deskripsi, status_tindak_lanjut, tindak_lanjut, foto, latitude, longitude, created_at FROM aduan_warga ORDER BY created_at DESC';
|
|
$result = $conn->query($sql);
|
|
|
|
if (!$result) {
|
|
http_response_code(500);
|
|
echo json_encode(['status' => 'error', 'message' => 'Query gagal: ' . $conn->error]);
|
|
$conn->close();
|
|
exit;
|
|
}
|
|
|
|
$data = [];
|
|
while ($row = $result->fetch_assoc()) {
|
|
$row['latitude'] = (float)$row['latitude'];
|
|
$row['longitude'] = (float)$row['longitude'];
|
|
$data[] = $row;
|
|
}
|
|
|
|
echo json_encode($data);
|
|
$conn->close();
|
|
?>
|