title: Turning PHP selection to JavaScript array for manipulation
body: <p>I want to add these images from my server to an JavaScript array so I can work with them.</p>
  
  <p>The example below should alert the number of images in the folder. At the moment there is two images in there and this script alerts me twice saying I've the length of the array is one. Obviously I want one alert saying two.</p>
  
  <pre><code>&lt;?php
      include("mysqlconnect.php");
  
      $select_query = "SELECT `ImagesPath` FROM `offerstbl` ORDER by `ImagesId` DESC";
      $sql = mysql_query($select_query) or die(mysql_error());   
      while($row = mysql_fetch_array($sql,MYSQL_BOTH)) {
  ?&gt;
  
  &lt;script&gt; var images = new Array("&lt;?php echo $row["ImagesPath"]; ?&gt;"); 
  alert(images.length);
  </code></pre>