0
我需要帮助解决我正在面临的问题将我的Google地图标记位置更新为mySQL。 我想在背景中发送这个标记的经度和纬度(即无需刷新页面)。我已经使用AJAX和PHP,但目前还没有运气。这可能是因为我是一个初学者。使用PHP和AJAX更新mySQL中的Google地图标记位置值
以下是我的工作:
需要在driver.php固定部分
/////Get latitude and longitude of the last created marker/////////
lg1= markerStart.getPosition().lng();
lt1= markerStart.getPosition().lat();
////I need help here- Please provide me with solution///////////
$.ajax({
url: "update.php",
type: "POST",
data: {'xCordinates': lg1,'yCordinates': lt1}
/*,
success: function() {
alert("ok");// This works
}*/
});
//alert(lg1+","+lt1); // This works (I get accurate altitude and longitude)
update.php
<?php
session_start();
$driverId = $_SESSION['driver_id'];
$driver_name = $_SESSION['name'];
include "header.php"; // access database
$xCordinates = $_POST['xCordinates']; // take value of xCordinates
$yCordinates = $_POST['yCordinates']; // take value of yCordinates
// Do not worry about the spelling mistakes below!
$updatevalue = "UPDATE driver SET xCornidates='$xCordinates', yCornidates='$yCordinates' WHERE driver_id='$driverId'";
$result1 = mysql_query($updatevalue) or die(mysql_error());
?>
我希望得到一个你的解决方案。谢谢!
我刚试过这个。这并没有解决问题。 –
好了,在这行之后加'echo $ updatevalue;'$ updatevalue =“UPDATE driver SET xCornidates = $ xCordinates,yCornidates = $ yCordinates WHERE driver_id = $ driverId”;'以查看查询。现在使用[Postman](https://www.getpostman.com/)发送帖子请求并获得回复。 – Orion
哦,我看到列名是xCornidates和yCornidates,我想这是一个错误,或者他们是你真正的列名? – Orion