In the code you’ve provided I can see two issues:
- you are overwriting the data in
$result
in the second call to mysql_query() - you are also looking for the current date (
NOW()
) to be between your constraints.
Assuming that you’re using a DATE or DATETIME column in MySQL rather than a VARCHAR you can do the following ($start and $end should be formatted as “yyyy-MM-dd”):
$sql = "SELECT * FROM preglediv1 WHERE [nameofdatecolumn] BETWEEN '" . $start . "' AND '" . $end . "' AND " .
"(`pregledali` LIKE '%".$query."%') OR (`pregleda1` LIKE '%".$query."%') OR (`pregleda2` LIKE '%".$query."%')";
$result = mysql_query($sql);
1
solved Date range filter does not work [closed]