通过使用PHP和AJAX更新mySQL中的Google地图标记位置值
Update Google Map marker position value in mySQL by using PHP and AJAX
我需要帮助来解决将我的谷歌地图标记位置更新到 mySQL 时遇到的问题。我想在后台发送此标记的纬度和经度(即不刷新页面)。我用过AJAX和PHP,但到目前为止还没有运气。这可能是因为我是两者的初学者。
以下是我的工作:
驱动程序中需要修复的部分.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)
更新.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());
?>
我希望从您那里得到解决方案。谢谢!
试试这个,改变
$updatevalue = "UPDATE driver SET xCornidates='$xCordinates', yCornidates='$yCordinates' WHERE driver_id='$driverId'";
自
$updatevalue = "UPDATE driver SET xCornidates=$xCordinates, yCornidates=$yCordinates WHERE driver_id=$driverId";
但请考虑重组以避免 SQL 注入。
相关文章:
- 是否可以控制获取哪些Google地图脚本(JavaScript API)
- 单击超链接时,如何使用Google Maps API v3缩放地图
- 在angularjs/google地图中显示分支最近的路线
- 创建类似于Google analytics的分析地图
- Javascript:Google Maps API:如果地图加载在隐藏容器中,则为空白地图
- 使用Google地图API v3显示多个标记
- 我是否应该在网站的每个页面上都包含 Google 地图脚本标签
- 使用自动完成服务()将 Google 地图地点限制为特定国家/地区
- Google 地图信息窗口仅显示首次点击时的信息
- 在 Google 地图 API V3 中启用和禁用大量标记
- 使用JavaScript获取Google地图上显示的所有推文时遇到麻烦
- Google Maps Javascript API v3 地图显示在桌面浏览器上,但不会显示在移动浏览器上
- 如何将waze事件标记添加到带有流量的google地图javascript API生成的地图
- 将PHP集成到Javascript中,使用Google API显示地图标记
- 如何制作Google Maps API v3六边形拼接地图,最好是基于坐标的
- Google Maps v3 API-在地图上绘制圆圈
- 外部SVG作为Google地图api标记-是或否
- Google Map JS API-加载地图分幅,但所有图像(标记、缩放控制等)都不加载;t负载2分钟
- 获取属性(邮政编码)并在Google地图API 3中使用
- 如何在PhoneGap中实现windows平台的地图(Google或Bing)