I have a search I've created for a database.
One of the options is to search by year '2006','2005','2004', etc.
The page:
search.php?year=$year&news_category=$news_category isn't working if they leave the year blank.
The first option in the drop-down form for news is set to value="". What I would like to do is if they select the value="" option for news to display all results, regardless of year, where news_category=$news_category
My query is
SELECT * FROM news WHERE YEAR(news_date)=" . $GET['year'] . " AND news_category = " . $GET['news_category'] . " ORDER BY news_date DESC
If I put in 2006 for year= in the URL it works, but if I leave year=&news_category it doesn't work.
Is there a way I can fix this?