我想在 php 中完成复选框绑定。我编写了以下代码来从数据库中获取数据:
$result = mysql_query("select * from users where kunnr='".$_SESSION["kunnr"]."'");
if(isset($page["id"]))
{
$result = mysql_query("select * from users where kunnr='".$_SESSION["kunnr"]."' and id='".$page["id"]."'");
}
$model['check']=array();
while($row = mysql_fetch_array($result)){
array_push($model['check'],
array(
"id"=>$row["id"],
"active"=>$row["active"],
"admin"=>$row["admin"],
"web"=>$row["web"],
"mstudio"=>$row["mstudio"],
"projectcentral"=>$row["projectcentral"],
"icenter"=>$row["icenter"],
"sales"=>$row["sales"],
"prospect_admin"=>$row["prospect_admin"],
"default_contact"=>$row["default_contact"],
"no_acts"=>$row["no_acts"],
"no_daily"=>$row["no_daily"],
"sync_exchange"=>$row["sync_exchange"]
));
}
在不同文件的视图内部如下:
<tbody data-bind="foreach: items" style="height:113px;">
<tr>
<td><a href="#" class="projectslink" data-bind="attr: {value: id, title: question}, text:question"></a></td>
<td><input type="checkbox" disabled data-bind="value: id, checked: active=='true'"/></td>
<td><input type="checkbox" disabled data-bind="value: id, checked: required=='true'"/></td>
<td><input type="checkbox" disabled data-bind="value: id, checked: required=='true'"/></td>
<td><input type="checkbox" disabled data-bind="value: id, checked: required=='true'"/></td>
<td><input type="checkbox" disabled data-bind="value: id, checked: required=='true'"/></td>
<td><input type="checkbox" disabled data-bind="value: id, checked: required=='true'"/></td>
</tr>
所以请建议我...