Hi all,

Here's my first post. I have a problem which I've worked on for a while now. I'm new to php, html, scripts, but I'm a very quick learner and have worked in IT for years, so hopefully someone can point me towards what I need to do/learn to sort this problem.

I've a really simple insert in my PHP:

mysql_query('INSERT INTO markers (date, time, name, address, lat, lng, type, type_image_url, debt, activity, text, notes, source)' .
    " VALUES ('$date','$time','$name', '$address', '$lat', '$long', '$type', 'http://www.phoenker.com/images/male2.png', '$debt', '$activity', '$text', '$notes','$source')");

that works fine. now I want to use a function to set the gps coordinates, which works fine. here is a piece of it:

// Try W3C Geolocation method (Preferred)
  if(navigator.geolocation) {
    browserSupportFlag = true;
    navigator.geolocation.getCurrentPosition(function(position) {
      initialLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
      contentString = "Location found using W3C standard" + position.coords.latitude;
      var teddylat = position.coords.latitude;
      map.setCenter(initialLocation);
      infowindow.setContent(contentString);
      infowindow.setPosition(initialLocation);
      infowindow.open(map);
    }, function() {
      handleNoGeolocation(browserSupportFlag);
    });

I know it works because if I put the position.coords.latitude into an alert, it displays fine.


So, my question/problem is, how do I take the value of 'position.coords.latitude' and use it in the insert whilst using just one php page. As a noob, I'm not sure how to make the variable global. See I know I can call a second php and $_GET; but I want to know how to do it within the same php page. I'd hope there was a way I can set the position.coords.latitude and position.coords.longitude into 'something' that I can refer to in the insert.

Do I need to learn ajax, parsing, err...?!?

Thanks

You google funtion is in javascript that runs in the brouwser,
all php is done and over (serverside) by that time.
so you have to call an external scipt or do a refrech with the the latlng as a hidden form element

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.