<table class="table table-striped">
<?php
$sql = "select * from quanxian";
$arr = $db->query($sql);
$sqlqx = "select Qxian from users where uid ='{$uid}'";//读取数据库
$qx =$db->strquery($sqlqx);
$arrqx = explode(',',$qx);//字符串转为数组
foreach($arr as $v)
{
if(in_array($v[0],$arrqx))// 编译查看不是在数组 中,在数组 中为选中状态
{
echo "<tr>
<td>
<input type='checkbox' checked='checked' class='qx' id='Qxian' value='$v[0]' /> {$v[1]}
</td>
</tr>";
}
else
{
echo "<tr>
<td>
<input type='checkbox' class='qx' id='Qxian' value='$v[0]' /> {$v[1]}
</td>
</tr>";
}
}
?>
</table>