PHP警告:in_array()期望参数2为数组,在/ var / www / toolbox中给出null

时间:2017-09-06 03:23:18

标签: php

我在DB中有数据,如showmember,memberform,newmember,editmemform我想检查复选框,如果值在数组中。

Data in DB

Checkbox

$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;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

&#13;
&#13;
<input type='checkbox' name='items[]' value='showmember' <?php if (is_array($accValues) && in_array('showmember',$accValues)){ echo $checked;} ?>> Show Member
&#13;
&#13;
&#13;