Hello I have the following question, I call the data in my database through the current year, with the following code:
<script>
$(document).on("ready", function(){
listar();
});
var listar = function(){
var table = $("#dt_cliente").DataTable({
"order": [[ 0, "desc" ]],
"destroy": true,
"ajax":{
"method": "POST",
"url" : "inc/listar.php"
},
"columns":[
{"data":"decreto"},
{"data":"anno"},
{"data":"materia"}
],
});
}
</script>
<?php
include 'conexion.php';
$anno=date("Y");
$query = "SELECT * FROM decreto WHERE fecha='$anno' ORDER BY decreto_id ASC;";
$resultado = mysqli_query($conexion, $query);
if (!$resultado) {
die("Error");
}else {
while ($data = mysqli_fetch_assoc($resultado)) {
$arreglo["data"][] = $data;
}
echo json_encode($arreglo);
}
mysqli_free_result($resultado);
mysqli_close($conexion);
My question would be if in the HTML I want to select a different date and that I load the data in the datatable with that date. I hope to be clear any question I will be aware of the post. Best regards