I have a search form and everything works perfectly. Problem is, there are 2 fields that, when left blank, kill my results.
For example, let's say I want to search for point totals by players with the last name Johnson. But I also have a field with a start and end date that I can use to narrow the search even further. Well, I can get that to work if the user enters dates. However, if the date fields are left blank, then no results show at all because the query sees empty dates and those, of course, don't match any results. Here's how I have it written:
$result = mysql_query("SELECT * FROM table_name WHERE Code LIKE '%$Code%' AND Delivery LIKE '%$Delivery%' AND Status LIKE '%$Status%' AND Manager LIKE '%$Manager%' AND Completion_Date BETWEEN '$start_date' AND '$end_date'");
I don't know how to make the between dates condition (not used if they are left blank).
Any ideas?