title: Pushing multiple rows of a SQL query into a single PHP array item
body: <p>I'm having a brain fart right now.  I'm pulling questions and possible answers from a database to dynamically generate a quiz using PHP and MySQL.  Here is the output I get:</p>
  
  <pre><code>    Response id: 3 Question id: 1 Question: What is my middle name? Title: How Well Do You Know Michael
      Array (
          [0] =&gt; Array (
              [r_id] =&gt; 3
              [question_id] =&gt; 1
              [question] =&gt; What is my middle name?
              [title] =&gt; How Well Do You Know Michael ) ) 
      Array (
          [0] =&gt; Array (
              [0] =&gt; 1
              [1] =&gt; Abe )
          [1] =&gt; Array (
              [0] =&gt; 2
              [1] =&gt; Andrew )
          [2] =&gt; Array (
              [0] =&gt; 3
              [1] =&gt; Andre )
          [3] =&gt; Array (
              [0] =&gt; 4
              [1] =&gt; Anderson ) ) 
  </code></pre>
  
  <p>from this PHP script:</p>
  
  <pre><code>// Grab the question data from the database to generate the form
      $query = "SELECT qr.response_id AS r_id, qr.question_id, q.question, quiz.title " . 
           "FROM quiz_response AS qr " . 
           "INNER JOIN question AS q USING (question_id) " . 
           "INNER JOIN quiz USING (quiz_id) " .
           "WHERE qr.user_id = '" . $_SESSION['user_id'] . "'";
      $data = mysqli_query($dbc, $query) or die("MySQL error: " . mysqli_error($dbc) . "&lt;hr&gt;\nQuery: $query");
      $questions = array(); 
      while ($row = mysqli_fetch_array($data, MYSQL_ASSOC)) {
          echo 'Response id: ' . $row['r_id'] . 'Question id: ' . $row['question_id'] . ' Question: ' . $row['question'] . ' Title: ' . $row['title'] . '&lt;br /&gt;';
          array_push($questions, $row);
          // Pull up the choices for each question
          $query2 = "SELECT choice_id, choice FROM question_choice " .
          "WHERE question_id = '" . $row['question_id'] . "'";
          $data2 = mysqli_query($dbc, $query2);
          $choices = array();
          while ($row2 = mysqli_fetch_array($data2, MYSQL_NUM))
              array_push($choices, $row2);
      }
      print_r($questions);
      print_r($choices);
  </code></pre>
  
  <p>However, I would ideally like to have just one item in the $choices array, as opposed to 4 separate items.  For example, I'd like the the choices array to look like the following:</p>
  
  <pre><code>Array (
      [0] =&gt; Array (
          [0] =&gt; 1
          [1] =&gt; Abe
          [2] =&gt; 2
          [3] =&gt; Andrew
          [4] =&gt; 3
          [5] =&gt; Andre
          [6] =&gt; 4
          [7] =&gt; Anderson )
  </code></pre>
  
  <p>My question: **Although I will have four separate rows from the `</p>
  
  <pre><code>while ($row2 = mysqli_fetch_array($data2, MYSQL_NUM))
              array_push($choices, $row2);
  </code></pre>
  
  <p>`is there anyway to push them all into the same item of the array $choices?**</p>