In the table in the database contains the column date, checkbox. How can I disable the checkbox if the inputted date is already in the database.For example, if in the table contains date = 13/9/2019 and checkbox = h1, then if we input the date 13/9/2019, the checkbox h1 is disabled and vice versa
$(document).ready(function {
$("#date").change(function {
var date = $("#date").val();
$.ajax({
url: "variable.php",
method: "POST",
data: {
date2: date
},
dataType: "text",
success: function(html) {
//what to put here?
}
});
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="date" id="date">
<input type="checkbox" name="checkbox[]" id="checkbox" name="h1">
<input type="checkbox" name="checkbox[]" id="checkbox" name="h2"">
<?php $db = mysqli_connect('localhost','root','','mydatabase');
if (isset($_POST['date2'])){
$query = mysqli_query($db, "SELECT * FROM mytable where date =
'".$_POST["date2"]."'");
// what to put here?
}
?>