I have two arraylists (longitude elements and latitude elements) which I want to pass them in the php script and then in 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
in the php I am writing something like this but I don t know how to continue:
if ($stmt = $mysqli->prepare("INSERT INTO route(latitude,longitude,trek_id_r)
values (?, ? , ? )"))
{
/* Set our params */
$lati[] = $_POST['Latitude_mysql[]'];
$longi[] = $_POST['Longitude_mysql[]'];
and then???
I need the latitude and longitude to be inserted respectively, i.e: if the values are:
Longitude_mysql: 30.24 , 50.24
Latitude_mysql: 23.43 , 24.56
trek_id_r= 2
in mysql in table route
I need this result:
Longitude | Latitude | Trek_id_r
30,24 | 23,43 | 2
50,24 | 24,56 | 2
I have read about converting the arraylists to json or implode and multiple mysqli insert so something relevant would be useful and understandable.
You need to iterate the coord list and insert each in mysql. You will have two inserts in this case