query($sql); $locations = []; 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()) { $locations[] = $row; } } echo json_encode($locations); $conn->close(); ?>