-2

I am making one project where I have to get longitude and latitude of user, to mark the place where the he is and so on. The problem is to save longitude and latitude in php variable, which at the end will be saved in MySQL database. So, does anyone know is that possible to achieve.

3
  • 2
    sure it can be achieved by sending the coordinates via ajax from js to php and save them to mysql or whatever. look for how to making an ajax call.. Commented Jan 19, 2014 at 11:37
  • 2
    what have you tried sofar no code no fiddle how can we help you if you don't tell us Commented Jan 19, 2014 at 11:39
  • Maybe this will help you out: stackoverflow.com/questions/19549439/… Commented Jan 19, 2014 at 11:54

1 Answer 1

0

See example here http://html5demos.com/geo. Than change it:

if (navigator.geolocation) {
 navigator.geolocation.getCurrentPosition(success, error);
} else {
 error('not supported');
}

function successFunction(position) {
   var lat = position.coords.latitude;
   var longi = position.coords.longitude;

   $.ajax({
      type: 'POST',
      data: { latitude : lat, longitude : longi },
      url: //....
      //... passing on server
   });
}
Sign up to request clarification or add additional context in comments.

1 Comment

This is not going to continuously store the lat lang

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.