title: Google maps - Multi markers from database longitude and lattitude not showing on the map
body: <p>I have this code that takes details from database and put them in php array that later is passed to javascript to generate Google map:</p>
  
  <pre><code>&lt;?php
  $query='select name,longitude,latitude from maps';
  $result=mysql_query($query) or die();
  $num_rows=mysql_num_rows($result);
  if($num_rows &gt; 0){
  for($i=0;$i&lt;$num_rows;$i++){
  $row=mysql_fetch_row($result);
  
  $location[]= $row[0].', '.$row[2].', '.$row[1].','.($i+1);
  
  
  }
  //this creates the following array
  array(4) { 
  [0]=&gt; string(44) "Travel agent Marko, 42.5624525, 27.5263493,1" 
  [1]=&gt; string(44) "Travel agent Marko, 42.5632957, 27.5267364,2" 
  [2]=&gt; string(54) "Travel agent 'Planet Travel', 42.5609811, 27.5263934,3" 
  [3]=&gt; string(56) "Travel agent 'Planet Travel' 2, 42.5642942, 27.5266121,4" 
  }
  
  ?&gt;
  &lt;script type="text/javascript"&gt;
  var loc = &lt;?php echo json_encode($location); ?&gt;;
  var locations = [
  [loc]
  ];
  
  
  var map = new google.maps.Map(document.getElementById('googlemap'), {
    zoom: 10,
    center: new google.maps.LatLng(42.5624525, 27.5263493),
    mapTypeId: google.maps.MapTypeId.ROADMAP
  });
  
  var infowindow = new google.maps.InfoWindow();
  
  var marker, i;
  alert(locations.length);
  
  for (i = 0; i &lt; locations.length; i++) { 
    marker = new google.maps.Marker({
      position: new google.maps.LatLng(locations[i][1], locations[i][2]),
      map: map
    });
  
    google.maps.event.addListener(marker, 'click', (function(marker, i) {
      return function() {
        infowindow.setContent(locations[i][0]);
        infowindow.open(map, marker);
      }
    })(marker, i));
  }
  &lt;/script&gt;
  
  &lt;?php
  }
  ?&gt;
  </code></pre>
  
  <p>my question is why markers don't appear on the map? No error is returned, but no markers too. 
  Do I have to move javascript code within php loop?
  if I alert locations.length I got 1 as locations.length. Why js count the array of locations as 1 location? Thanks in advance !</p>