Hey I'm read the status of the lamp with $status. Now I want the color of the button to change depending on whether the lamp is on or off. For that the variable $status needs to be updated continuously, but I don't know how to do this. I tried with a while(true) loop but then the website keeps loading and loading. Hope you can help me :)
<?php
if (isset($_POST['lampe1'])){
$status= exec('gpio -g read 23');
if($status==0){
shell_exec("gpio -g write 23 1"); //switching lamp on
}else{
shell_exec("gpio -g write 23 0"); //switching lamp of
}
}
?>
<html>
<body>
<form method="post">
<p>
<button name="lampe1" style="<?php $status= exec('gpio -g read 23'); if($status==0){echo" color:black;"}?>";>Switch</button>
//changes button color depending on $status :)
//but when the button will be clicked on any other device/tab, it will be out of date :(
</p>
</form>
</body>
</html>