query("update sekolah_maps set maps=''where kode='".$kode."'"); if (!$results) { header('HTTP/1.1 500 Error: Could not delete Markers!'); exit(); } exit("Done!"); } $kode = filter_var($_POST["kode"], FILTER_SANITIZE_STRING); $check_data = $mysqli->query("SELECT count(id) as hitung FROM sekolah_maps where kode='".$kode."'"); $obj = $check_data->fetch_object(); if ($obj->hitung=="0") { $results = $mysqli->query("INSERT INTO sekolah_maps (kode,maps) VALUES ($kode,$gabung)"); } else { $results = $mysqli->query("update sekolah_maps set maps='$gabung' where kode='".$kode."'"); } if (!$results) { header('HTTP/1.1 500 Error: Could not create marker!'); exit(); } exit(); } ################ Continue generating Map XML ################# //Create a new DOMDocument object $dom = new DOMDocument("1.0"); $node = $dom->createElement("markers"); //Create new element node $parnode = $dom->appendChild($node); //make the node show up // Select all the rows in the markers table $kode = $_REQUEST["kode"]; $results = $mysqli->query("SELECT * FROM sekolah_maps WHERE kode='".$kode."'"); if (!$results) { header('HTTP/1.1 500 Error: Could not get markers!'); exit(); } //set document header to text/xml header("Content-type: text/xml"); // Iterate through the rows, adding XML nodes for each while($obj = $results->fetch_object()) { $loc = (explode(",",$obj->maps)); $node = $dom->createElement("marker"); $newnode = $parnode->appendChild($node); $newnode->setAttribute("lat", $loc[0]); $newnode->setAttribute("lng", $loc[1]); } echo $dom->saveXML();