javascript - How to save Google Maps V3 distance result to MySQL database? -
(and sorry in advance being such basic question @ core)
i have mysql database location info, , php script can put new, user-submitted location database. want (immediately) find distances between newly-submitted location , subset of existing locations in database using google maps directions request, , store these distances in database.
i can select locations subset via php , use javascript fetch distance data google maps, how transfer these javascript variables database? -what's best way save group of javascript variables separate entries in mysql database?
thanks help!
carl
if have distances loaded variables in js code, can make xmlhttprequest send them server php script put them database. pseudo-code this:
js:
function storedistance(pointid1, pointid2, distance) { var xhr = new xmlhttprequest(); xhr.open("post", "/savedistance.php", true); xhr.send("pid1=" + pointid1 + "&pid2=" + pointid2 + "&distance=" + distance); }
php:
$pointid1 = $_post['pid1']; $pointid2 = $_post['pid2']; $distance = $_post['distance']; mysql_query("insert distances values ($pointid1, $pointid2, $distance)");
Comments
Post a Comment