38 lines
1013 B
PHP
38 lines
1013 B
PHP
<?php
|
|
header('Content-Type: application/json');
|
|
|
|
// Konfigurasi Database (Sesuaikan dengan milik Anda)
|
|
$host = "localhost";
|
|
$user = "root";
|
|
$pass = "";
|
|
$db = "webgis"; // UBAH INI
|
|
|
|
$conn = new mysqli($host, $user, $pass, $db);
|
|
|
|
if ($conn->connect_error) {
|
|
echo json_encode(["status" => "error", "message" => "Koneksi database gagal"]);
|
|
exit;
|
|
}
|
|
|
|
$data = json_decode(file_get_contents("php://input"), true);
|
|
|
|
if ($data && isset($data['id'])) {
|
|
$id = $data['id'];
|
|
|
|
// Hapus data dari tabel jalan_polyline berdasarkan ID
|
|
$stmt = $conn->prepare("DELETE FROM jalan_polyline WHERE id = ?");
|
|
$stmt->bind_param("i", $id);
|
|
|
|
if ($stmt->execute()) {
|
|
echo json_encode(["status" => "success", "message" => "Garis jalan berhasil dihapus"]);
|
|
} else {
|
|
echo json_encode(["status" => "error", "message" => "Gagal menghapus data: " . $stmt->error]);
|
|
}
|
|
|
|
$stmt->close();
|
|
} else {
|
|
echo json_encode(["status" => "error", "message" => "ID tidak valid"]);
|
|
}
|
|
|
|
$conn->close();
|
|
?>
|