title: Import SQL Data into JS Array
body: <p>I want to display a map that shows an array of markers. I'am using OSM with the OpenLayers Library to do that. If I use static values everything works fine. But now I want to display markers that are in a SQL table. What's the best way to get the data and fill it into the JS array?</p>
  
  <p>This is my code:</p>
  
  <pre><code>        &lt;script&gt;
          map = new OpenLayers.Map("mapdiv");
          map.addLayer(new OpenLayers.Layer.OSM());
  
          var size = new OpenLayers.Size(10,10);
          var icon = new OpenLayers.Icon('img/marker.gif', size);
  
          epsg4326 =  new OpenLayers.Projection("EPSG:4326"); //WGS 1984 projection
          projectTo = map.getProjectionObject(); //The map projection (Spherical Mercator)
  
          var lonLat = new OpenLayers.LonLat( 8.289166666666, 46.834444444444 ) .transform(epsg4326, projectTo);
  
          var zoom=8;
          map.setCenter (lonLat, zoom);
  
          // var markers = new OpenLayers.Layer.Markers( "Markers" );
          // map.addLayer(markers);
  
          // markers.addMarker(new OpenLayers.Marker(lonLat, icon));
  
          var vectorLayer = new OpenLayers.Layer.Vector("Overlay");
  
          // Define an array.
          var markers = [ 
  
          // SQL DATA NEEDS TO GO HERE! Formated like this: 
          //  [47.153339352283,8.51886974582752],
          //  [47.5047313406471,8.76598280071111],
          //  [47.3085363748528,8.598335445835]
  
          ];
  
          //Loop through the markers array
          for (var i=0; i&lt;markers.length; i++) {
  
              var lon = markers[i][1];
              var lat = markers[i][0];
  
              var feature = new OpenLayers.Feature.Vector(
                      new OpenLayers.Geometry.Point( lon, lat ).transform(epsg4326, projectTo),
                      {description: "marker number " + i} ,
                      {externalGraphic: 'img/marker.gif', graphicHeight: 10, graphicWidth: 10, }
                  );             
              vectorLayer.addFeatures(feature);
          }                        
  
          map.addLayer(vectorLayer);
  
      &lt;/script&gt;
  </code></pre>
  
  <p>SQL table:</p>
  
  <p><img src="https://i.stack.imgur.com/67dje.png" alt="http://i.stack.imgur.com/OLZIc.png"></p>
  
  <p>Thank you :)</p>