当管理员在表格中输入一行或更多行并点击批准按钮时,该行数据(request_id是主键)应在数据库字段is_approved中更新,并应将“待定”更改为“已批准” is_approved字段有两个枚举:待定和已批准。 我怎么能这样做?
<form action = "admin.php" method = "post">
<input type="button" name="accept" value="accept" />
<input type="hidden" name="submitted" value="TRUE" />
</form>
PHP代码:
if(!empty($_POST['accept'])) {
$request_id = $_POST['request_id'];
foreach($request_id as $is_approved) {
$query = mysql_query("UPDATE request SET is_approved = 'approved' where is_approved =$request_id");
}
}
答案 0 :(得分:0)
将表单更改为:
<form action = "admin.php" method = "post">
<input type="button" name="accept" value="accept" />
<input type="text" name="request_id[]" value=1/>
<input type="text" name="request_id[]" value=2/>
<input type="hidden" name="submitted" value="TRUE" />
</form>
该值应为您的实际request_id