I need to query my database from a button, and I've had problems with that.
I have a "button" or an "a" or an "input type" and I want to change a record with the "onclick", that is, if I press the button, the "state" field of my table will change. "available" to "busy".
I've been seeing what can be done with ajax which takes up your PHP function but does not work
<input type="submit" onclick="accion();">
<script>
function accion()
{
$.ajax({
type:'POST',
url: 'boton.php',
success:function (){
alert('Bien');
},
error:function (){
alert("mal");
}
});
}
</script>
and this I have in "boton.php"
<?php
$con=mysqli_connect("localhost","root","","sm");
mysqli_query($con,"UPDATE Lunes set EstadoL="Ocupado";");
?>
I hope you can help me, if I deploy the alert but until then