title: Save mysql query result into a PHP array
body: <p>Here is the situation: </p>
  
  <p>I have this array in PHP, which is intended to keep the data from the result of a query: </p>
  
  <pre><code>$returnData = array(
      'ID'                 =&gt; '',
      'NAME'               =&gt; '', 
      'DESCRIPTION'        =&gt; '',
      'STATUS'             =&gt; '',
      'STATUS_DESCRIPTION' =&gt; '',
      'LOCATION'           =&gt; '',
      '_ERROR'             =&gt; ''
  );
  </code></pre>
  
  <p>I later execute a query where I would like to fill this array: </p>
  
  <pre><code>$fetchResourceQuery = sprintf('SELECT  RESOURCEID, RESOURCENAME, RESOURCEDESCRIPTION,
                                             T3.RESOURCELOCATIONNAME, T2.RESOURCESTATUSNAME,
                                             T2.RESOURCESTATUSDESCRIPTION
                                     FROM resource          T1
                                     JOIN resource_status   T2
                                     ON T1.RESOURCESTATUSID = T2.RESOURCESTATUSID
                                     JOIN resource_location T3
                                     ON T1.RESOURCELOCATIONID = T3.RESOURCELOCATIONID');
  
  $resultSet = $DB-&gt;query($fetchResourceQuery);
          if($resultSet){
              while($row = $resultSet-&gt;fetch_assoc()){
                  $returnData['ID']                   = $row['RESOURCEID'];
                  $returnData['NAME']                 = $row['RESOURCENAME'];
                  $returnData['DESCRIPTION']          = $row['RESOURCEDESCRIPTION'];
                  $returnData['STATUS']               = $row['RESOURCESTATUSNAME'];
                  $returnData['STATUS_DESCRIPTION']   = $row['RESOURCESTATUSDESCRIPTION'];
                  $returnData['LOCATION']             = $row['RESOURCELOCATIONNAME'];
              }
              $json_data = json_encode($returnData, JSON_UNESCAPED_SLASHES);
              echo $json_data;
          }
  </code></pre>
  
  <p>So far this is good. The problem is, I think there is only one cycle inside the while worth of data being saved, then it overwrites inside the array for some reason, the output is this: </p>
  
  <pre><code>{"ID":"456","NAME":"Rack con Televisor #1","DESCRIPTION":"Televisor Sharp Aquos con Laptop, armado en 2011.","STATUS":"Active","STATUS_DESCRIPTION":"Can be reserved.","LOCATION":"First Floor, High School","_ERROR":""}
  </code></pre>
  
  <p>This is bad because there are 5 resources in the database, and only one of them is being stored.</p>
  
  <p>How can I make the array store several values like a josn object? Since apparently the soultion I'm trying right now is not working. </p>