I have a checkbox and everytime I click on it, the state is recorded into a MySQL database. How would it be possible to refresh the state of the checkbox every 5 seconds (using Ajax - setInterval), taking the state value from the database?
At the moment, the code looks like this:
<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>