title: How to set an Array in Javascript dynamically?
body: <p>I am working on an e-commerce website. There is an array "products" in javascript defined by the following code</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      var products = 
      [
           {"id":"1","title":"Apple iPhone 4"},
           {"id":"2","title":"BlackBerry 9780 Bold"}
      ];
      /*some other javascript code*/
  &lt;/script&gt;
  </code></pre>
  
  <p>I want this array to be updated dynamically according to the number of rows returned by querying the database. 
  For example, suppose I query the database and 5 rows are returned. I want this array to be updated with those 5 rows. Please help me getting this done. I am using PHP, MySQL, Apache on Windows machine.</p>