What happens is that I'm working with google maps api and I have a database with some shops, the database is the direction of these, that with a javascript get the distance between the store and the location of user, the topic I want to sort by proximity, what I did was a first page which calculates all away and then redirects the following format "pagina.php?data=(ID, DISTANCE),(ID, DISTANCE), ..... "
then get the parameter
<?php $data = $ _GET['data'] ?> // and example of "data" -> "(1,1582),(2,3568)," end with comma
And I'm trying to use this command "" THAT WORKS IN phpMYAdmin ""
CREATE TEMPORARY TABLE distancias_temporales (id int(50) NOT NULL, distancia DECIMAL(12,2) NOT NULL DEFAULT 0.00);
INSERT INTO distancias_temporales (id, distancia) VALUES (1, 14.25), (2, 13.34);
SELECT * FROM talleres,distancias_temporales WHERE distancias_temporales.id = talleres.ID ORDER BY distancia ASC;
Of course to do dynamic change values:
$ data = "(-1, -1)";
if (isset ($ _GET ['data'])) {
$ data = $ _GET ['data']. "(-1, -1)";
}
and in the second line:
"INSERT INTO d (id, distancia) VALUES ".$data.";";
but mysql send my an error according to what he tells me the page, the code is sent as I want
But it does not work when I try to put on the page ...
anyone can help me, the problem I think would be the multi query
MySQL can handle multiple insert statements. Barmar makes a good point that some connection managers do not handle that construct.
Assuming the SQL is sent unaltered, it appears a comma is missing in the assignment of $data.
$ data = $ _GET ['data']. "(-1, -1)";
should be...
$data = $ _GET['data'] . ", (-1, -1)";
If and only if the value $_GET['data'] is not empty, e.g. data="(ID, DISTANCE),(ID, DISTANCE)".