I'm working on a section where I have to filter photos depending on the data they enter in the inputs. The inputs I have are:
- 1 input text for the title
- 2 inputs date to set a date range for the photos
- 1 input to select the country
The fact is that when collecting the data and making the following query:
$sentencia = "SELECT fichero, titulo, fecha, pais FROM fotos WHERE titulo LIKE '%$titulo%' OR fecha >= STR_TO_DATE('$desde', '%Y %m %d') AND fecha <= STR_TO_DATE('$hasta', '%Y %m %d') OR pais = '$pais'";
PROBLEM: I have placed some example dates in the inputs of the dates to check the correct functioning, but what happens is that it brings back all the photos, even those with the date = NULL in the database.
Can someone help me? Thanks.