我在DB中有数据,如showmember,memberform,newmember,editmemform我想检查复选框,如果值在数组中。
$ret = mysqli_query($db_conn," SELECT * FROM gt_accesslist WHERE GP_ID = $id");
if(!$ret)
{
echo mysqli_error($db_conn);
exit;
}
while($row = mysqli_fetch_array($ret))
{
$checked = 'checked="checked"';
$accValues = explode(',', $row['ACL_NAME']);
}
<input type='checkbox' name='items[]' value='showmember' "; if (in_array('showmember',$accValues)){ echo $checked;} echo"> Show Member
&#13;
答案 0 :(得分:0)
<input type='checkbox' name='items[]' value='showmember' <?php if (is_array($accValues) && in_array('showmember',$accValues)){ echo $checked;} ?>> Show Member
&#13;