title: Combining two query results - php, mysql
body: <p>So I'm doing something wrong (new to PHP) and I think the issue is related to my inexperience with manipulating arrays in php.</p>
  
  <pre><code>    $query2 = "SELECT * FROM birds where breed = '".$row['breed']."' and wing_span = '".$row['wing_span']."' and id != '".$row['id']."' limit 4";
      $s_query = mysql_query($query2);
  
      $theArray = array();
  
      $counter = 0;
      while($row3 = mysql_fetch_assoc($s_query)) {
          $counter = $counter + 1;
          array_push($theArray, $row3);
      }
  
      if($counter &lt; 4) {
          $new_limit = 4 - $counter;
  
          $query5 = "SELECT * FROM birds where breed = '".$row['breed']."' and id != '".$row['id']."' limit ".$new_limit."";
          $s_query2 = mysql_query($query5);
  
          $counter = 0;
          while($row5 = mysql_fetch_assoc($s_query2)) {
              $counter = $counter + 1;
              array_push($theArray, $row5);
          }
      }
  </code></pre>
  
  <p>The goal is that if I don't reach the maximum of 4 in the first query, I will run a second query with the difference in MAX - count as the limit. But when I run that query, I try to add the rows ($s2_query) to the existing rows ($s_query)</p>
  
  <p>In this attempt, I tried to create a new array, push the elements as I go. I've tried manually combining them too (array_merge), but also didn't work.</p>
  
  <p><strong>Edit</strong>
  It's intentional for there to be two queries. Point is that if the first query doesn't give me a total of 4 results, I run a second query to fill the remaining spots.</p>