As I explained in the title, I want to create a sql query on my php page, to return specific results in function of the existence of the variables. I have a form on the top of my page, with some inputs (date, name, etc...) and when I click, I refresh the page with the right results.
Currently my syntax is :
if (isset($_POST['dated']) && $_POST['dated'] != null){
$doleances = $bdd->prepare('SELECT * FROM doleance WHERE Priorite < 5 AND Date >= ? ORDER BY ID DESC');
$doleances->execute(array($newDate));
}
else if (isset($_POST['dated']) && $_POST['dated'] != null && isset($_POST['datef']) && $_POST['datef'] != null){
$doleances = $bdd->prepare('SELECT * FROM doleance WHERE Priorite < 5 AND Date BETWEEN ? AND ? ORDER BY ID DESC');
$doleances->execute(array($newDate, $newDate2));
}
else if{...}
else if{...}
...
But I think there's a much better way to do that... Thanks in advance