title: passing coordinates from mysql to js via php
body: <p>So, i've a working js script that calls a php script that executes a mysql query.
  The bad part is when i try to pass the coordinates back to the js script because they are unformatted.
  Example:
  the array i would like to have is {xx.xxxxxxx, yy.yyyyyyy...}
  instead i get {xx.xxxxxxxyy.yyyyyyy and so on}.
  here is the php query code UPDATED:</p>
  
  <pre><code>&lt;?php 
  include('config.php'); //richiama lo script per la connessione al database
  
  $org_name=$_POST['valor']; //riceve il nome dell'organizzazione terroristica desiderata
  
  $return = array();
  $query=mysql_query("SELECT longitude, latitude FROM gtdb WHERE `gname` LIKE '$org_name%' and longitude!=''"); //esegue una query al database
  while($row=mysql_fetch_assoc($query)&amp;&amp;$row2=mysql_fetch_assoc($query)){
      $return[] = array($row['longitude'], $row2['latitude']);
  }
  header('Content-type: application/json');
  echo json_encode($return);
  ?&gt;
  </code></pre>
  
  <p>here is the javascript code that triggers the query, when it gets back the datas from the query calls the dataadder function (see the next section of js code):</p>
  
  <pre><code>var Datas = [new google.maps.LatLng(32.7603282, 46.343451)];
  $(document).ready(function() {
  $('#gnome').change(function() {
      var inpval=$(this).val();
      $.ajax({
          url: 'php/query.php',
          type: 'post',
          data: {valor : inpval},
          success: function(data) {
              while(Datas.length &gt; 0) {
                 Datas.pop();
              }
              alert(data);
              Datas = dataadder(data);
              initialize(); //reinitialize gmap with the new datas
                              alert(Datas);
          }
      });
  });
  });
  </code></pre>
  
  <p>dataadder code</p>
  
  <pre><code>function dataadder(array){
  var arr2 = [];
  var i=0;
  var j=1;
  while(j&lt;=array.length){
      arr2.push("new google.maps.LatLng("+array[i]+")");
      i+=2;
      j+=2;
  }
  alert(arr2);
  return(arr2);
  }
  </code></pre>
  
  <p>Any help?</p>