diff --git a/ambil.php b/ambil.php index e689f4b..9a06e2f 100644 --- a/ambil.php +++ b/ambil.php @@ -1,13 +1,8 @@ query("SELECT * FROM spbu"); - +require_once 'koneksi.php'; +header('Content-Type: application/json'); +$result = $conn->query("SELECT * FROM spbu ORDER BY id DESC"); $data = []; - -while($row = $result->fetch_assoc()){ - $data[] = $row; -} - +while ($row = $result->fetch_assoc()) { $data[] = $row; } echo json_encode($data); -?> \ No newline at end of file +?> diff --git a/ambil_jalan.php b/ambil_jalan.php index fd73aa6..0d99d12 100644 --- a/ambil_jalan.php +++ b/ambil_jalan.php @@ -1,7 +1,8 @@ query("SELECT * FROM jalan"); -$data=[]; -while($row=$result->fetch_assoc()) $data[]=$row; +require_once 'koneksi.php'; +header('Content-Type: application/json'); +$result = $conn->query("SELECT * FROM jalan ORDER BY id DESC"); +$data = []; +while ($row = $result->fetch_assoc()) { $data[] = $row; } echo json_encode($data); -?> \ No newline at end of file +?> diff --git a/ambil_kavling.php b/ambil_kavling.php index a71e3e5..d2f2246 100644 --- a/ambil_kavling.php +++ b/ambil_kavling.php @@ -1,7 +1,8 @@ query("SELECT * FROM kavling"); -$data=[]; -while($row=$result->fetch_assoc()) $data[]=$row; +require_once 'koneksi.php'; +header('Content-Type: application/json'); +$result = $conn->query("SELECT * FROM kavling ORDER BY id DESC"); +$data = []; +while ($row = $result->fetch_assoc()) { $data[] = $row; } echo json_encode($data); -?> \ No newline at end of file +?>