In this tutorial of a google mashup
I don’t understand the insertion via this code
// Insert new row with user data
$query = sprintf(“INSERT INTO markers " .
" (id, name, address, lat, lng, type ) " .
" VALUES (NULL, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’);”,
It seems to me that, instead of this,
" VALUES (NULL, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’);",
the code should be this :
" VALUES (NULL, '$name ', '$address ', ‘$lat’, ‘$lng’, ‘$type’);",
How does the insert commande send the right values when we simply put in
" VALUES (NULL, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’);",
Here’s what I don’t understand : at the beginning of the php code, we create these variables from values in the Get array passed by the URL.
$name = $_GET[‘name’];
$address = $_GET[‘address’];
$lat = $_GET[‘lat’];
$lng = $_GET[‘lng’];
$type = $_GET[‘type’];
Wasn’t the purpose of the above bit of code to create variables whose values we then insert into the table ?
I expect us to do this sort of thing :
// Insert new row with user data
$query = sprintf(“INSERT INTO markers " .
" (id, name, address, lat, lng, type ) " .
" VALUES (NULL, '$name ', '$address ', ‘$lat’, ‘$lng’, ‘$type’);”,
But it looks af we create those variables, $name, etc. and then never use them again.
Thanks for setting me straight !