当我想在某个日期之间搜索数据时,亲切的先生是正确的mysqli
声明。
实施例。我输入"待定",即reservationstatus
然后从日期选择器中选择(2017/8/28),该日期选择器将成为from_date并选择另一个日期(2017/8/30),这将是至今。
结果必须是2017/8/28至2017/8/30之间的待处理预订状态。
先谢谢你,希望你能帮助我。
$query = "
SELECT * FROM reservations
WHERE firstname LIKE '".$search."'
OR lastname LIKE '".$search."'
OR emailaddress LIKE '%".$search."%'
OR contactnumber LIKE '%".$search."%'
OR speaker LIKE '".$search."'
OR topic LIKE '%".$search."%'
OR location LIKE '%".$search."%'
OR audience LIKE '%".$search."%'
OR count LIKE '%".$search."%'
OR time LIKE '%".$search."%'
OR date LIKE '%".$search."%'
OR reservationdate LIKE '%".$search."%'
OR reservationtime LIKE '%".$search."%'
OR reservationstatus LIKE '%".$search."%'
AND date BETWEEN '".$_POST["from_date"]."' AND '".$_POST["to_date"]."'";
答案 0 :(得分:2)
$query = "
SELECT * FROM reservations
WHERE (firstname LIKE '".$search."'
OR lastname LIKE '".$search."'
OR emailaddress LIKE '%".$search."%'
OR contactnumber LIKE '%".$search."%'
OR speaker LIKE '".$search."'
OR topic LIKE '%".$search."%'
OR location LIKE '%".$search."%'
OR audience LIKE '%".$search."%'
OR count LIKE '%".$search."%'
OR time LIKE '%".$search."%'
OR date LIKE '%".$search."%'
OR reservationdate LIKE '%".$search."%'
OR reservationtime LIKE '%".$search."%'
OR reservationstatus LIKE '%".$search."%')
AND date BETWEEN '".$_POST["from_date"]."'
AND '".$_POST["to_date"]."'";
为所有OR子句添加功能括号将解决该错误。