此代码选择正确检查的复选框的 ID,但是它从我的第一个选择中选择下拉选择,而不是我更改的选择下拉列表。有没有办法来解决这个问题?我在用着
<select name="status[]"><option value="1">active</option><option value="0">inactive</option></select>
这是我的流程代码。
if (isset($_POST['submit'])) {
// find out how many records there are to update
$size = count($_POST['id']);
// start a loop in order to update each record
$i = 0;
while ($i < $size) {
// define each variable
$id = $_POST['id'][$i];
$status= $_POST['status'][$i];
// do the update and print out some info just to provide some visual feedback
$query = "UPDATE users SET status = '$status' WHERE id = '$id' LIMIT 1";
mysql_query($query) or die ("Error in query: $query");
print "$status | $id<br /><br /><em>Updated!</em><br /><br />";
++$i;
}
mysql_close();
}