【发布时间】:2020-10-09 11:59:28
【问题描述】:
我有一个包含其他字段的表单,我在复选框数组中有一个客户列表。要获得该列表,我使用数据库表字段并填充列表。 HTML 表单
<? if($this->clientCount > 0){?>
<? foreach($this->client as $valuec) {?>
<input type="checkbox" name="banner_allowed1[]" value="<?=$valuec['company_id']?>" <?if($valuec['banner_allowed']==1){echo 'checked="checked"';}?> style="margin:auto; size:20px;"> <?=$valuec['title']?></label><br>
<?}?>
<?}?>
现在,当我提交表单时,我需要知道哪些未选中,因为表单会加载从数据库中选择的值。我需要将未选择的数据库表字段值更新为零(0)。 我发现动态复选框很难进行名称值对或获取未选中复选框的值,因为帖子不会发送未选中的复选框值
MY submit page in POST, only getting checked checkbox values
if(!empty($_POST['banner_allowed1'])){
foreach($_POST['banner_allowed1'] as $clientid1){
$update['userid'] = $uid;
$update['banner_allowed'] = 1;
$this->db->update('clientlist', $update, "id=$clientid1");
}
} else {
}
【问题讨论】:
-
简单在 php 页面中比较 mysql 和已选择的,然后减去,现在您有了未选择值的新数组
-
请告诉我如何减去原始数组和发布的数组。新手
标签: javascript php html