27 lines
769 B
PHP
27 lines
769 B
PHP
<?php
|
|
header("Content-Type: application/json; charset=UTF-8");
|
|
include_once '../db_connect.php';
|
|
|
|
$query = "SELECT * FROM penduduk_miskin";
|
|
$result = $conn->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']
|
|
);
|
|
array_push($arr, $item);
|
|
}
|
|
echo json_encode(["status" => "success", "data" => $arr]);
|
|
} else {
|
|
echo json_encode(["status" => "success", "data" => []]);
|
|
}
|
|
?>
|