title: How to send a different Session Array each iteration of a while loop?
body: <p>I'm having trouble sending userID's from a list to a different php page. Here's my code:</p>
  
  <pre><code>$eventName = $row['Name'];
  $_SESSION['event'] = $eventName;
  $users= array();
      while($row2 = mysqli_fetch_array($result2)){
  
          echo "&lt;li&gt;".$row2['FirstName']." ".$row2['LastName']; // print the members
  
          $userID = $row2['ID'];
          $users[] = $row2['ID'];             
          $_SESSION['users'] = $users; //creates session array
          echo "&lt;a href ='removeFromEvent.php?id=$userID&amp;event=$eventName'&gt;&lt;span class = 'REMOVE'&gt;Remove&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;br&gt;";
  
      }
  
  
      echo implode('&lt;br&gt;',$_SESSION['users']); //prints the IDs
      echo "&lt;br&gt;". $_SESSION['event'];
      echo "&lt;a href ='test.php'&gt;&lt;span class = 'REMOVE'&gt;ADD CREDITS&lt;/span&gt;&lt;/a&gt;";
  </code></pre>
  
  <p>So with this code, it will print out the ID's and the name of the event at the end of each list of names on the page. But when I click on the link to move to test.php, it only shows the ID's and event name for the last event in the list. Here's all the code in test.php: </p>
  
  <pre><code>&lt;?php
      session_start();
      echo implode('&lt;br&gt;',$_SESSION['users']);
      echo $_SESSION['event'];
  
  ?&gt;
  </code></pre>
  
  <p>Here's how the page looks on the site:</p>
  
  <blockquote>
  <pre><code>EVENT1 NAME
     1. Member1                            REMOVE
     2. Member2                            REMOVE
                                           ADD CREDITS (call this the first link)
     member1ID
     member2ID
       event1name
  EVENT2 NAME
    1. Member1                                REMOVE
                                           ADD CREDITS (and this is the second)
     member1ID
       event2name
  </code></pre>
  </blockquote>
  
  <p>When I click the first add credits link, it opens up test.php, but prints event2name and member1 for event2. When I click the second add credits link, it opens up test.php, and also prints the same event name and members. 
  The number of events and members is dependent on how many are created in the database, so there could be 2 events with 2 members in each, or 20 events, all with a different number of members.</p>
  
  <p>So my question is, how can I get the first link to show the first event's members and event name, and the second link  to show the second event's members and event names?</p>