正如我在标题中解释的那样,我想在我的 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{...}
...
但我认为有更好的方法来做到这一点......提前谢谢