title: Moving data from SQL database to an array in JavaScript via PHP
body: <p>Ive been trying this for hours now but it wont quite get there.</p>
  
  <p>I have a database which amongst other things contains geocodes, lat and lon. I have accessed these using the following PHP</p>
  
  <pre><code>&lt;?php
   mysql_connect("localhost", "tompublic", "public") or die(mysql_error()); 
   mysql_select_db("first_section") or die(mysql_error()); 
  
  $data = mysql_query("SELECT geo_lat, geo_lon FROM first_page_data")
  or die(mysql_error());
  while ($row = mysql_fetch_assoc($data)){
  $lat[] = $row['geo_lat'];
  $lon[] = $row['geo_lon'];
  }
  ?&gt;
  </code></pre>
  
  <p>These values in <code>$lat</code> and <code>$lon</code> then need to be put into an array in a javascript function like so:</p>
  
  <pre><code>var latit = [];
  var longi = [];
  latit = '&lt;?php echo $lat[]; ?&gt;';
  longi = '&lt;?php echo $lon[]; ?&gt;';
  </code></pre>
  
  <p>But it wont work! Any ideas?</p>