【发布时间】:2017-09-09 11:56:01
【问题描述】:
我需要根据 mysql 数据库中的值使用引导开关设置复选框的状态。
我正在尝试像这样使用 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>';
}
开关检查状态似乎是随机的,而不是基于我从数据库接收到的值。
【问题讨论】:
标签: php jquery twitter-bootstrap bootstrap-switch