我正在尝试创建一个表单,该表单允许用户编辑多个成员的信息,获取该信息,并通过 URL 传递它来编辑数据库。到目前为止我有这个:
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);
在页面顶部,我试图获取数组以编辑数据库:
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");
}
我试图将数据从 http_build_query 传递到 URL,然后在顶部检索它,但我不知道应该如何将多个数组添加到 URL 中,然后将三个数组分开以获得三个不同的数组从中获取信息。谢谢!