I can't change the state of a value with a href. I have tried in all ways. Here is my code
 <a href="giallo.php?id=' . $row['id'] . '">Giallo</a>  
giallo.php=
<?php
                            
// Create connection
$conn = new mysqli('localhost','root','','agenda');
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}
 
$id = $_GET['id']; 
$qry = mysqli_query($db,"select * from note where id='$id'"); // select query
// when click on Update button
if(isset($_POST['update'])) {
    $colore=1;
    
    $edit = mysqli_query($db,"update note set colore='$colore' where id='$id'");
    
    if($edit) {
        mysqli_close($db); // Close connection
        header("location:udienze.php"); // redirects to all records page
        exit;
    } else {
        echo mysqli_error();
    }   
}
if (mysqli_query($conn, $sql)) {
    echo "<script>
    alert('Nota inserita correttamente');
    window.location.href='add-udienze.php';
    </script>";
} else {
    echo "<script>
    alert('Errore');
    window.location.href='add-udienze.php';
    </script>";
}
    
mysqli_close($conn);
?>
What is wrong with my code? There are probably cleaner ways to do it. I have tried all ways that I know.
 
     
    