I have a MySQL fulltext search engine and I want to allow the user to filter results by adding a range of years for the results. I have a column called year that has years ranging from 1999 to 2011. How do I alter my mysql_query to reflect this? The variable $fyear is the year that the user wanted to begin at (lower end), and $tyear is the year to end at (higher end).
<?php
mysql_connect("localhost", "root", "root");
mysql_select_db("database");
$var = @$_GET['q'];
$fyear = @$_GET['from_year'];
$tyear = @$_GET['to_year'];
if (isset($var)) {
$sql = mysql_query("SELECT *, MATCH(subj_name, course_name) AGAINST ('$var')
AS score from table1 WHERE MATCH (subj_name, course_name) AGAINST('$var')
ORDER BY score desc");
}
NOTE: The column year is an integer field
Have a look at the operator between.