title: Using php to create customized google map
body: <p>I am trying to create a custom google map using Longitudes and Latitudes that I have in my sql database. So I am trying to place these results directly into my jquery code for the geocoder. But it is not working. Does anyone have ANY idea how I could do this?? I have looked up everything possible and can not find an answer. Thank you so much in advance. Here is my code:</p>
  
  <pre><code>&lt;script type='text/javascript'&gt;//&lt;![CDATA[ 
  
  var map;
  var global_markers = []; 
  [&lt;?php 
  include 'admin/dbconn.php';
  
  $getLoc = mysql_query("SELECT * FROM EanHotels WHERE City = 'Acapulco'") or die(mysql_error());
  while($row = mysql_fetch_array($getLoc)){
      $name = $row['name'];
      $lat = $row['Latitud'];
      $lon = $row['Longitude'];
      $address = $row['Address1'];
      echo $lat;
      echo $lon;
  
  ?&gt;   
  var markers = [[&lt;?php echo $lat ?&gt;, &lt;?php echo $lon ?&gt;, '&lt;?php echo $name ?&gt;'], &lt;?php } ?&gt;
  ];
  
  
  var infowindow = new google.maps.InfoWindow({});
  
  function initialize() {
      geocoder = new google.maps.Geocoder();
      var latlng = new google.maps.LatLng(40.77627, -73.910965);
      var myOptions = {
          zoom: 1,
          center: latlng,
          mapTypeId: google.maps.MapTypeId.ROADMAP
      }
      map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
      addMarker();
  }
  
  function addMarker() {
      for (var i = 0; i &lt; markers.length; i++) {
          // obtain the attribues of each marker
          var lat = parseFloat(markers[i][0]);
          var lng = parseFloat(markers[i][1]);
          var trailhead_name = markers[i][2];
  
          var myLatlng = new google.maps.LatLng(lat, lng);
  
          var contentString = "&lt;html&gt;&lt;body&gt;&lt;div&gt;&lt;p&gt;&lt;h2&gt;" + trailhead_name + "&lt;/h2&gt;&lt;/p&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;";
  
          var marker = new google.maps.Marker({
              position: myLatlng,
              map: map,
              title: "Coordinates: " + lat + " , " + lng + " | Trailhead name: " + trailhead_name
          });
  
          marker['infowindow'] = contentString;
  
          global_markers[i] = marker;
  
          google.maps.event.addListener(global_markers[i], 'click', function() {
              infowindow.setContent(this['infowindow']);
              infowindow.open(map, this);
          });
      }
  }
  
  window.onload = initialize;
  //]]&gt;  
  
  &lt;/script&gt;
  </code></pre>