I'm having trouble sending userID's from a list to a different php page. Here's my code:
$eventName = $row['Name'];
$_SESSION['event'] = $eventName;
$users= array();
while($row2 = mysqli_fetch_array($result2)){
echo "<li>".$row2['FirstName']." ".$row2['LastName']; // print the members
$userID = $row2['ID'];
$users[] = $row2['ID'];
$_SESSION['users'] = $users; //creates session array
echo "<a href ='removeFromEvent.php?id=$userID&event=$eventName'><span class = 'REMOVE'>Remove</span></a></li><br>";
}
echo implode('<br>',$_SESSION['users']); //prints the IDs
echo "<br>". $_SESSION['event'];
echo "<a href ='test.php'><span class = 'REMOVE'>ADD CREDITS</span></a>";
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:
<?php
session_start();
echo implode('<br>',$_SESSION['users']);
echo $_SESSION['event'];
?>
Here's how the page looks on the site:
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
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.
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?