title: Calling a JavaScript function in PHP for Google Map
body: <p>hopefully you can help me. I have read a lot of forums regarding this but still cannot get what I wanted. I'm using PHP/MySQL to run my system. I already had a code in JavaScript that will allow the user to add a place and the system can add that place in the Google Map (embedded in my site) as a marker. Now, what I wanted is to add the coordinates of that new place in my database and then my map will just get the markers from the database for adding in the map. </p>
  
  <p>Currently, what I did is to get the latitude and longitude of the added place from the javascript then was able to pass them to my php script within the same file. The latitude and longitude can  be added in my database but I do not know now how to go back again to JavaScript so that I can add my markers.</p>
  
  <p>What is the best way to do this? Is/Are there better approaches to solve this?</p>
  
  <pre><code>&lt;?php
  $marker = array();
  if(isset($_GET['set'])){
      $lat = $_GET['lat'];
      $long = $_GET['longi'];
      $newadd = $_GET['newAdd'];
  
      $connect = mysql_connect("localhost","root","");
      mysql_select_db("mapping");
      $query=mysql_query("INSERT INTO markers VALUES('','','$newadd','$lat','$long','')");
  
  }
  ?&gt;
  </code></pre>
  
  <p>My JavaScript to place markers</p>
  
  <pre><code>function addMarkers(){
          var tempMarker;
          var tabs = [];
          var blueIcon = new GIcon(G_DEFAULT_ICON);
          blueIcon.image = "http://maps.google.com/mapfiles/ms/micons/green-dot.png";
  
          // Set up our GMarkerOptions object
          markerOptions = { icon:blueIcon };
  // for loop get data from db and loop it
          tempMarker = new GMarker(tempLatLng,markerOptions);
          //if(tabs.length==0){
              tabs[ctr] = [new GInfoWindowTab('Greetings','Hi! Welcome'), new GInfoWindowTab('My Info',tempMarker.getLatLng().toString())];
          //}
          tabInfoWindow(tempMarker,tabs, ctr);
          markerArray.push(tempMarker);
          displayMarkers();
      }
  }
  </code></pre>
  
  <p>Thanks!</p>