[英]arraylists of longitude and latitude pass them in php and insert them to mysql,how?
我有两个arraylist(经度元素和纬度元素),我想在php脚本中然后在mysql(wamp)中传递它们。
for (int i = 0; i < Latitude_mysql.size(); i++)
{
nameValuePairs.add(new BasicNameValuePair("Latitude_mysql",Latitude_mysql.get(i)));
nameValuePairs.add(new BasicNameValuePair("Longitude_mysql",Longitude_mysql.get(i)));
}//by this way I send them in php script,but I m not sure if it is the appropriate
在PHP中,我正在写这样的东西,但我不知道如何继续:
if ($stmt = $mysqli->prepare("INSERT INTO route(latitude,longitude,trek_id_r)
values (?, ? , ? )"))
{
/* Set our params */
$lati[] = $_POST['Latitude_mysql[]'];
$longi[] = $_POST['Longitude_mysql[]'];
接着???
我需要分别插入纬度和经度,即:如果值是:
Longitude_mysql: 30.24 , 50.24
Latitude_mysql: 23.43 , 24.56
trek_id_r= 2
在MySQL的表route
我需要这个结果:
Longitude | Latitude | Trek_id_r
30,24 | 23,43 | 2
50,24 | 24,56 | 2
我已经读过有关将arraylists转换为json或爆破以及多个mysqli插入的内容,因此相关的内容将是有用且可理解的。
您需要迭代协调列表,并将每个列表插入mysql中。 在这种情况下,您将有两个插入
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.