Project UAS Sistem Informasi Geografis (SIG)
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
include 'db.php';
|
||||
|
||||
$id = intval($_GET['id'] ?? 0);
|
||||
$type = $_GET['type'] ?? '';
|
||||
|
||||
if ($id == 0 || $type == '') {
|
||||
echo json_encode(["message" => "Parameter tidak valid"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$table = '';
|
||||
if ($type == 'point') $table = 'spbu';
|
||||
if ($type == 'line') $table = 'jalan';
|
||||
if ($type == 'polygon') $table = 'parsil';
|
||||
if ($type == 'masjid') $table = 'masjid';
|
||||
if ($type == 'penduduk') $table = 'penduduk_miskin';
|
||||
|
||||
if ($table == '') {
|
||||
echo json_encode(["message" => "Type tidak dikenali"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("DELETE FROM $table WHERE id = ?");
|
||||
$stmt->bind_param("i", $id);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(["message" => "Data berhasil dihapus"]);
|
||||
} else {
|
||||
echo json_encode(["message" => "Gagal hapus", "error" => $stmt->error]);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user