I'm trying to create a form which allows a user to edit multiple members' information, taking that information in, and passing it through the URL to edit the database. I have this so far:
echo "<form id='memberEditor' method='post' action='massEditor.php'>"
$result = mysql_query("SELECT * FROM `user_trials` ORDER BY `grade` ASC, `lastName` ASC");
while($row = mysql_fetch_array($result)){
$studentID = $row['studentid'];
$ID = array();
array_push($ID, $studentID);
$firstName = $row['name'];
$lastName = $row['lastName'];
$fullName = $firstName." ".$lastName;
$money = $row['money'];
$moneyValue = array();
array_push($moneyValue, $money);
$waiver = $row['waiver'];
$waiverValue = array();
array_push($waiverValue, $waiver);
echo "<tr>";
echo "<td>$studentID</td>";
echo "<td>$fullName </td>";
echo "<td><input type='checkbox' name='money' id='money'".(($money == 'yes')?'checked ':' ')."value='yes' /></td>";
echo "<td><input type='checkbox' name='waiver' id='waiver'".(($waiver == 'yes')?'"checked"':' ')."value='yes' /></td>";
echo "</tr>";
}
$queryID = http_build_query($studentID);
$queryMoney = http_build_query($moneyValue);
$queryWaiver = http_build_query($waiverValue);
and at the top of the page, where I'm trying to get the arrays in order to edit the database:
ini_set('display_errors', 'On');
error_reporting(E_ALL);
$memberNumbers = count($ID);
for($i = 0; $i < $memberNumbers; $i++) {
$studentid = $ID[$i];
$result = mysql_query("SELECT * FROM `user` WHERE `studentid`='$studentid' LIMIT 1");
$news = mysql_fetch_array($result);
$cash = $moneyValue[$i];
$permission = $waiverValue[$i];
mysql_query("UPDATE `user_trials` SET `money`='$cash', `waiver`='$permission' WHERE `studentid`='$studentid' LIMIT 1");
header("Location: view_members.php");
}
I've tried to pass the the data from http_build_query into the URL and then retrieving it at the top, but I have no idea as to how I am supposed to add multiple arrays into the URL and then separate the three in order to have three distinct arrays to get information from. Thanks!