1
我需要使用bootstrap-switch基于mysql数据库中的值设置复选框的状态。使用PHP或jQuery设置Bootstrap-Switch复选框选中状态
我想用PHP这样做,但它似乎没有工作,代码是摘录:
while ($row = $result->fetch_assoc()) {
$checkdevicestate = $row["devicestatus"];
if ($checkdevicestate == "false") {
$devstatus = "";
} else if ($checkdevicestate == "true") {
$devicestatus = "checked";
}
$devicecontent .= '<tr><td style="width:60%"><span data-icon="7" class="linea-icon linea-basic fa-fw"></span>'. $row["devicename"] .'</td><td style="width:100%"><input type="checkbox" id="' . $row["devicecode"].'" '.$devicestatus.' class="devicebtn"data-on-color="info" data-size="small"data-off-color="danger"></td></tr>';
}
开关检查状态似乎随机的,不是基于价值我从DB接收。
谢谢!我根据你的建议修改了我的代码。感谢您的帮助:) – Bruno
不客气:) – borracciaBlu