タイトルで説明したように、変数の存在の関数で特定の結果を返すために、php ページで sql クエリを作成したいと考えています。ページの上部にいくつかの入力 (日付、名前など) を含むフォームがあり、クリックすると正しい結果でページが更新されます。
現在、私の構文は次のとおりです。
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{...}
...
しかし、それを行うにはもっと良い方法があると思います...よろしくお願いします