query($query); $arr = array(); if($result->num_rows > 0) { while($row = $result->fetch_assoc()) { $item = array( "id" => $row['id'], "nama" => $row['nama'], "kategori_bantuan" => $row['kategori_bantuan'], "jumlah_jiwa" => isset($row['jumlah_jiwa']) ? (int)$row['jumlah_jiwa'] : 1, "lat" => (float)$row['lat'], "lng" => (float)$row['lng'], "foto_rumah" => $row['foto_rumah'], "foto_kk" => $row['foto_kk'] ); array_push($arr, $item); } echo json_encode(["status" => "success", "data" => $arr]); } else { echo json_encode(["status" => "success", "data" => []]); } ?>