-3
Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../quiz.css" rel="stylesheet" type="text/css">
<title>Administrator Approval</title>
</head>

<body>
<br><h2><div  class=head1>User Approval</div></h2>
<table width="75%" align="center" bordercolor="#000000" cellpadding="5px"border="1">
  <tr>
    <th scope="col">Select&nbsp;</th>
    <th scope="col">User Id&nbsp;</th>
    <th scope="col">Login&nbsp;</th>
    <th scope="col">Password&nbsp;</th>
    <th scope="col">Username&nbsp;</th>
    <th scope="col">Address&nbsp;</th>
    <th scope="col">City &nbsp;</th>
    <th scope="col">Phone&nbsp;</th>
    <th scope="col">Email&nbsp;</th>
  </tr>
 <?php
 extract($_POST);
 $query=mysql_query('select * from approval');
 while($row=mysql_fetch_array($query)){
 echo"<tr>";
 echo"<form action='approve.php' method='post'>";
 echo"<td align='center'><input type='checkbox' name='approve' value='$row[0]'> &nbsp</td>";
 echo"<td align='center'>$row[0] &nbsp;</td>
    <td align='center'>$row[1] &nbsp;</td>
    <td align='center'>$row[2] &nbsp;</td>
    <td align='center'>$row[3] &nbsp;</td>
    <td align='center'>$row[4] &nbsp;</td>
    <td align='center'>$row[5] &nbsp;</td>
    <td align='center'>$row[6] &nbsp;</td>
    <td align='center'>$row[7] &nbsp;</td>
  </tr>";
 }

echo"<td colspan='9' align='center'><input type='submit' name='submit' value='Approve'></td>";
echo"</table>";
echo"</form>";
?>
</body>
</html>

上面的(不完整的)文件是供管理员批准学生帐户的。正如您所见,从批准表中选择的条目已添加到用户表中,但user_id(即行 [0])可以是多个,因为我提供了复选框。我想在单个“提交”任何建议时将该用户 ID 的(多个)数据插入到用户表中?

4

1 回答 1

2

更改name='approve'name=approve[]。然后approve.php您可以将其作为数组访问:

foreach ($_POST['approve'] as $userid) {
    // Code to approve $userid
}
于 2013-10-12T18:25:09.367 回答