I'm trying to make an Array that is populated by database content from PHP in my Javascript
<p>I'm trying to make an Array that is populated by database content from PHP in my Javascript but when I call on it, it says undefined I'm not sure if I have this setup properly but I basically want to loop and make an array with 2 values, the latitude and longitude, this is what I have so far</p>

<pre><code>&lt;script&gt;
var initialLocation;
var map;
var markersArray = [];
var gMarkerArray = new Array();
&lt;?php
/* Gather all information from database so we can load all the markers */
$i = 0;
while($stmt -&gt; fetch()) {
  $i++;
?&gt;

gMarkerArray[&lt;?php echo $i; ?&gt;]="&lt;?php echo $gLatitude; ?&gt;,&lt;?php echo $gLongitude; ?&gt;";

&lt;?php
}
$stmt -&gt; close();
$mysqli -&gt; close();
/* End of script */
?&gt;

function initialize() {
  var mapOptions = {
  zoom: 15,
  center: new google.maps.LatLng(-34.397, 150.644),
  mapTypeId: google.maps.MapTypeId.ROADMAP,
  disableDefaultUI: false,
  zoomControl: true,
  zoomControlOptions: {
    style: google.maps.ZoomControlStyle.LARGE
  }
};

  map = new google.maps.Map(document.getElementById('gmaps'),
  mapOptions);

  google.maps.event.addListener(map, 'click', function(event) {
    var latitude = event.latLng.lat();
    var longitude = event.latLng.lng();
    deleteOverlays();
    addMarker(event.latLng);
    updateTextFields(latitude, longitude);
  });

  google.maps.event.addListener(marker, 'click', function(event) {
    showInfo(window);
  });

}


function updateTextFields(lati, longi) {
  $('#inputLatitude').val(lati);
  $('#inputLongitude').val(longi);
}


function addMarker(location) {
  marker = new google.maps.Marker({
    position: location,
    map: map
  });
  markersArray.push(marker);
}

function deleteOverlays() {
  if (markersArray) {
    for (i in markersArray) {
      markersArray[i].setMap(null);
    }
    markersArray.length = 0;
  }
}

function loadScript() {
  var script = document.createElement('script');
  script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=true&amp;' +
  'callback=initialize';
  document.body.appendChild(script);
}

$(document).ready(function() {
$(window).resize(function () {
    var h = $(window).height(),
        offsetTop = 190; // Calculate the top offset

    $('#gmaps').css('height', (h - offsetTop));
  }).resize();
  window.onload = loadScript;
});


&lt;/script&gt;
</code></pre>

<p>and the database content is being loaded just fine, I just need to know how to set the array up properly in Javascript.</p>
