【发布时间】:2014-01-22 02:21:34
【问题描述】:
我有一个复选框,每次单击它时,状态都会记录到 MySQL 数据库中。 怎么可能每 5 秒刷新一次复选框的状态(使用 Ajax - setInterval),从数据库中获取状态值?
目前,代码如下所示:
<div class="onoffswitch">
<input type="hidden" id="hidden1" value="6">
<input type="checkbox" name="onoffswitch1" class="onoffswitch-checkbox" id="myonoffswitch1"
<?php
$query3=mysql_query("select * from choice where id=6");
$query4=mysql_fetch_array($query3);
if($query4['choice']=="1")
{
echo "checked";
}
?>>
<label class="onoffswitch-label" for="myonoffswitch1">
<div class="onoffswitch-inner"></div>
<div class="onoffswitch-switch"></div>
</label>
</div>
【问题讨论】: