您可以像这样在 php 中获取变量:
$lat = $_REQUEST['lat'];
$lng = $_REQUEST['lng'];
然后你可以在你的数据库中插入 $lat 和 $lng。
例子:
function launchQuery($call)
{
$link = mysqli_init();
if (!$link) {
die('mysqli_init failed');
}
if (!mysqli_options($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT = 1')) {
die('Setting MYSQLI_INIT_COMMAND failed');
}
if (!mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, 5)) {
die('Setting MYSQLI_OPT_CONNECT_TIMEOUT failed');
}
if (!mysqli_real_connect($link, $dbhost, $dbuser, $dbpassword, $dbname, $dbport)) {
die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
}
mysqli_query($link,"SET NAMES 'utf8'");
$rs = mysqli_query($link, $call);
mysqli_close($link);
return $rs;
}
launchQuery("insert into whatever_your_table_name_is (latitude, longitude) values (".$lat.",".$lng.");");