query($sql); $data = []; if (!$result) { http_response_code(500); echo json_encode(['status' => 'error', 'message' => 'Query gagal: ' . $conn->error]); $conn->close(); exit; } if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $row['latitude'] = (float)$row['latitude']; $row['longitude'] = (float)$row['longitude']; $row['jumlah_anggota'] = (int)$row['jumlah_anggota']; $row['rumah_ibadah_id'] = $row['rumah_ibadah_id'] !== null ? (int)$row['rumah_ibadah_id'] : null; $row['jarak_ke_rumah_ibadah_m'] = $row['jarak_ke_rumah_ibadah_m'] !== null ? (float)$row['jarak_ke_rumah_ibadah_m'] : null; $row['bantuan_status'] = $row['bantuan_status'] ?: 'belum'; $row['bantuan_catatan'] = $row['bantuan_catatan'] ?? ''; $data[] = $row; } } echo json_encode($data); $conn->close(); ?>