1
I’m using the Materialize Framework, in it I have a button (Switche) that switches between ON and OFF, just in html, I wanted to insert this into a Mysql database, all in real time, by pressing the button, it changes the value in the database, 0 to OFF and 1 to ON, when pressing the button, if in the database is 0 change to 1, and see and versa, if in the databank is 1, the button must remain on, that is, symbolizing the ON! (The button in materialize I a checkbox, checked should be equal to ON)
HTML:
<div class="switch">
<label>
Off
<input type="checkbox">
<span class="lever"></span>
On
</label>
</div>
In PHP I thought of something like this:
$valor = $_POST['Switche'];
if($valor == 1){
$valor = 0;
}else{
$valor = 1;
}
How can I do this and update in real-time data stream ?
What if I wanted multiple checkboxs? Just out of curiosity, I’m not the author of the question.
– Samuel Verissimo