After some research and little afford from myself I got this:
$query .= "SELECT * FROM users WHERE birthday < SUBDATE(NOW(), INTERVAL BETWEEN $min AND $max YEAR)";
Although this doesn't work.
Users birthdays are stored in: 1991-01-01 in the birthday column. I have two fields in my form, that you can enter numbers in. example, 18 and 22.
then it will show all users that has the age between 18 and 22 ( 18,19,20,21,22).
^ And that is what im trying to filter out, with the query. But ive done something wrong, and maybe you cant do BETWEEN in INTERVAL, or what is wrong?
Im getting:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BETWEEN 17 AND 21 YEAR)' at line 1