我有一个起点和终点的纬度和经度,例如跟随。
1->Start:23.03234692854866,72.45964050292969 End:23.02823945776033,72.52281188964844 2-> Start:23.02823945776033,72.52281188964844 End:23.037402105360147,72.58907318115234 3->Start:23.037402105360147,72.58907318115234 End:23.036770218630025,72.6309585571289
这里,第一个的结束值是第二个的开始值(见上限值的粗体部分)。
问题是当我尝试插入它时,它没有按我的意愿插入。它是这样插入的:
意味着,这里有很多事情发生了变化。就像最后插入的第一个数据一样。
那么问题是什么?
JAVASCRIPT CODE:
function save_waypoints()
{var ac;
var ad;
var k="1";
for (var m=0;m<tot_marker;m++)
{
ac +=k+"->Start:"+lat_arr[m].location+","+lon_arr[m].location+" End:"+lat_arr[m+1].location+","+lon_arr[m+1].location+","+k+"====<br>";
document.getElementById('e').innerHTML=ac;
var w=[],wp;
var rleg = directionsDisplay.directions.routes[0].legs[m];
/*data.start = {'lat': rleg.start_location.lat(), 'lng':rleg.start_location.lng()}
data.end = {'lat': rleg.end_location.lat(), 'lng':rleg.end_location.lng()}*/
data.start = {'lat': lat_arr[m].location, 'lng':lon_arr[m].location}
data.end = {'lat': lat_arr[m+1].location, 'lng':lon_arr[m+1].location}
var wp = rleg.via_waypoints
for(var i=0;i<wp.length;i++)w[i] = [wp[i].lat(),wp[i].lng()]
data.waypoints = w;
var str = JSON.stringify(data)
var jax = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
jax.open('POST','process.php');
jax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
jax.send('command=save&mapdata='+str)
jax.onreadystatechange = function(){ if(jax.readyState==4) {
if(jax.responseText.indexOf('bien')+1)alert('Updated');
else alert(jax.responseText)
}}
k++;
}
}
PHP
<? ob_start(); header('Cache-Control: no-store, no-cache, must-revalidate');
mysql_connect('localhost','cron','1234');
mysql_select_db('mapdir');
if($_REQUEST['command']=='save')
{
$data = $_REQUEST['mapdata'];
//$query = "update mapdir set value='$data'";
$query = "insert into `mapdir`(`value`) values('$data')";
if(mysql_query($query))die('bien');
die(mysql_error());
}
if($_REQUEST['command']=='fetch')
{
$query = "select value from mapdir";
/*if(!($res = mysql_query($query)))die(mysql_error());
$rs = mysql_fetch_array($res,1);
die($rs['value']);*/
$qry=mysql_query($query);
/*$rs = mysql_fetch_array($qry,1);
echo $rs['value'];*/
$ja = array();
while($rs = mysql_fetch_array($qry))
{
array_push($ja,$rs['value']);
}
echo json_encode($ja);
}
?>
I am aware of deprecated function.