美好的一天。我是一个PHP新手。获取复选框的值
我想要做的是我想从我的数据库中获取特定数据行的id。并更新我的桌子上的一些列。
我所做的这是什么..
<td style="width:50px;"><input type="checkbox" id="chkPending" name="chkPending[]" value="<?php echo $row['RequestNumber']; ?>"/></td>
<td><a href="edit.php?id=<?php echo $row['RequestNumber']; ?>"><span class="label label-success">View Details</span></a></td>
<td style="width:100px;"><?php echo $row['RequestNumber']; ?></td>
<td style="width:100px;"><?php echo $row['Requestor']; ?></td>
<td style="width:100px;"><?php echo $row['Department']; ?></td>
<td style="width:50px;"><?php echo $row['category']; ?></td>
<td style="width:100px;"><?php echo $row['AssignedTo']; ?></td>
<td style="width:100px;"><?php echo $row['status']; ?></td>
<td style="width:100px;"><?php echo $row['DateRequested']; ?></td>
<td style="width:100px;"><?php echo $row['TimeRequested']; ?></td>
PHP代码
<?php
$RequestNumber = $POST_['chkPending'];
$sql = "UPDATE tblrequest SET Assignedto = 'personnel', status = 'Assigned' WHERE RequestNumber = '$RequestNumber'";
if (isset($_POST['submit'])) {
$success = mysql_query($sql) or die(mysql_error());
mysql_close();
}
if ($success == TRUE) {
?>
<script>
alert('You have successfully update account.');
</script>
<?php
}
?>
我希望得到任何帮助。先谢谢你。
这是我的全部代码:**
First:$ RequestNumber = $ POST _ ['chkPending'];你需要把它写成$ RequestNumber = $ _POST ['chkPending']; – Goikiu
我的不好。我改变了它,但仍然不起作用 – rapidoodle
请记住你的var $ RequestNumber是一个数据数组......如果我正确记得它需要以不同的方式处理。 – Goikiu