如何在PHP中对MySQL发起多个查询?

如何在PHP中对MySQL发起多个查询?,php,mysql,web,mysqli,Php,Mysql,Web,Mysqli,上面的不完整文件用于管理员对学生帐户进行审批。正如您所看到的,审批表中的选定条目添加到用户表中,但用户_idi.e行[0]可以是多个,因为我提供了复选框。我想将该用户id的多个数据插入到单个用户表中提交任何建议?将name='approve'更改为name=approve[]。然后在approve.php中,您可以将其作为数组访问: Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> &l

上面的不完整文件用于管理员对学生帐户进行审批。正如您所看到的,审批表中的选定条目添加到用户表中,但用户_idi.e行[0]可以是多个,因为我提供了复选框。我想将该用户id的多个数据插入到单个用户表中提交任何建议?

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

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>

google:sql transactionsftr:不要将表格用于表格数据以外的任何内容!表单不是表格数据。这在语义上是不正确的,您失去了很多样式设置的可能性,等等。此外,您的代码/示例还有很多问题,imho:在一行中打开,但在循环中打开,回显输出HTML而不是打开/关闭,使用不推荐的mysql函数,不清理输入SQL注入,XHTML1.1 doctype,…+1是不必要的狗屁解决方案!谢谢
foreach ($_POST['approve'] as $userid) {
    // Code to approve $userid
}