【发布时间】:2025-12-24 16:20:17
【问题描述】:
当管理员在表中勾选一行或多行并单击批准按钮时,该行数据(request_id 是主键)应在数据库字段 is_approved 中更新,并应将“待定”更改为“已批准” is_approved 字段有两个枚举:pending 和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");
}
}
【问题讨论】:
-
使用 $is_approved 更改查询中的 $request_id
-
注意未定义索引:request_id
-
你遇到了什么问题
-
您没有以
request_id作为帖子的表单,您的表单只有submitted -
request_id 未以形式传递。它应该是一个数组