28 lines
590 B
PHP
28 lines
590 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
require_once __DIR__ . '/db.php';
|
|
|
|
$sql = 'SELECT id, nama, no, status_24jam, latitude, longitude, created_at FROM spbu_points ORDER BY id DESC';
|
|
$result = $connection->query($sql);
|
|
|
|
if (!$result) {
|
|
http_response_code(500);
|
|
echo json_encode([
|
|
'success' => false,
|
|
'message' => 'Gagal mengambil data: ' . $connection->error,
|
|
]);
|
|
exit;
|
|
}
|
|
|
|
$points = [];
|
|
while ($row = $result->fetch_assoc()) {
|
|
$points[] = $row;
|
|
}
|
|
|
|
echo json_encode([
|
|
'success' => true,
|
|
'data' => $points,
|
|
]); |