title: Fetch all rows based on the query into an array
body: <p>I have the following code:</p>
  
  <pre><code>  //--------------------------------------------------------------------------
    // 2) Query database for data
    //--------------------------------------------------------------------------
    $result = mysql_query("SELECT * FROM $tableName");          //query
    $array = mysql_fetch_row($result);                          //fetch result   
  
    //--------------------------------------------------------------------------
    // 3) echo result as json 
    //--------------------------------------------------------------------------
    echo json_encode($array);
  </code></pre>
  
  <p>What I would like to do is fetch all rows based on the query and feed those into the array, to give me an output like this:</p>
  
  <pre><code>["1", "", "", "", "", ""]
  ["2", "", "", "", "", ""]
  etc...
  </code></pre>
  
  <p>I presume I need to loop through the rows and build up the array but I don't know how.</p>