J
Jeff
Hey
I'm having problem with the code below, it don't update the database. I've
posted both the javascript and the php script, but I think the error is in
the javascript below. When I click in the map a new marker is placed exactly
where I clicked in the map, then a alert displays the url I'm sending in
request.open... the url is okay... Maybe it's because I didn't set a
function to request.onreadystatechange??
JavaScript part:
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(63.4415, 10.4289 ), 13);
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
GEvent.addListener(map, "click", function(marker, point) {
map.clearOverlays();
var marker = new GMarker(point);
map.addOverlay(marker);
var request = GXmlHttp.create();
var url = "index.php?mode=loc&opt=3&id=4";
url = url + "&lng=" + point.lng();
url = url + "&lat=" + point.lat();
alert(url);
request.open("GET", url, true);
});
}
}
This is the PHP (version 5.2.0) code:
<?php
$lattitude = $_POST["lattitude"];
$longitude = $_POST["longitude"];
@include("config.php");
@ $db = new mysqli($host, $user, $dbpwd, $database);
if (!empty($lattitude) && !empty($longitude)) {
$id = $_POST["id"];
$sql = "update Location set Lattitude = " . $lattitude . ", Longitude = "
.. $longitude . " where Id = " . $id;
$result = $db->query($sql);
$db->close();
}
?>
any suggestions?
jeff
I'm having problem with the code below, it don't update the database. I've
posted both the javascript and the php script, but I think the error is in
the javascript below. When I click in the map a new marker is placed exactly
where I clicked in the map, then a alert displays the url I'm sending in
request.open... the url is okay... Maybe it's because I didn't set a
function to request.onreadystatechange??
JavaScript part:
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(63.4415, 10.4289 ), 13);
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
GEvent.addListener(map, "click", function(marker, point) {
map.clearOverlays();
var marker = new GMarker(point);
map.addOverlay(marker);
var request = GXmlHttp.create();
var url = "index.php?mode=loc&opt=3&id=4";
url = url + "&lng=" + point.lng();
url = url + "&lat=" + point.lat();
alert(url);
request.open("GET", url, true);
});
}
}
This is the PHP (version 5.2.0) code:
<?php
$lattitude = $_POST["lattitude"];
$longitude = $_POST["longitude"];
@include("config.php");
@ $db = new mysqli($host, $user, $dbpwd, $database);
if (!empty($lattitude) && !empty($longitude)) {
$id = $_POST["id"];
$sql = "update Location set Lattitude = " . $lattitude . ", Longitude = "
.. $longitude . " where Id = " . $id;
$result = $db->query($sql);
$db->close();
}
?>
any suggestions?
jeff