title: Search results while loop php
body: <p>So there's probably  a really simple way to sort this issue but at the moment I'm stumped for some reason. I'm working on a practice project, setting up a basic social network. I've created a basic php/ mysql search function for users to search for other users by querying the database, which functions like this:
  1. User types in name of other user onto serach form on own profile page
  2. This redirects them to a "search friends" php page which queries the database and locates similar records to the search. 
  3. The page redirects to a results page, where the original user can see the mini profiles of the other users.</p>
  
  <p>My issue is this: how to send the data produced from the while loop to the results page.</p>
  
  <pre><code>$resulting = mysqli_query($con, "SELECT * FROM $tbl_name WHERE LastName LIKE '%$secondquery%'
                              OR LastName LIKE '%$firstquery%'
                              OR LastName LIKE '%$thirdquery%'
                              OR LastName LIKE '%$fourthquery%'
                              OR FirstName LIKE '%$secondquery%'
                              OR FirstName LIKE '%$firstquery%'
                              OR FirstName LIKE '%$thirdquery%'
                              OR FirstName LIKE '%$fourthquery%'
                              ");
      $counting = mysqli_num_rows($resulting);
      if($counting != 0){
  
      while($row = mysqli_fetch_array($resulting))
       {
           echo $row['FirstName'] . " " . $row['LastName'] . "&lt;br&gt;";
  
           }
  
           mysqli_close($con);
          header("location: results.php");
  </code></pre>
  
  <p>I thought about doing something like:</p>
  
  <pre><code>while($row = mysqli_fetch_array($resulting))
       {
          if($n = 1){
           $_SESSION['a'] = $row['FirstName'] . " " . $row['LastName'] . "&lt;br&gt;";
           $n = 2;
          }elseif($n = 2){
          $_SESSION['b'] = $row['FirstName'] . " " . $row['LastName'] . "&lt;br&gt;";
          $n = 3;
          }
           }
  
           mysqli_close($con);
          header("location: results.php");
  </code></pre>
  
  <p>and then echoing the sessions on the results page but it relies too heavily on copy pasting etc. and I haven't got it working yet anyway. Anyone with any ideas on how best to approach this?</p>
  
  <p>Grateful for any help!</p>