Forum Moderators: coopster
I have an issue...
My sql query only recognizes the release_date inputs; neglecting the value in the first text field with a dropdown list option as well as the checkboxes that are selected...
Thing is... my advanced search function has 3 text fields and [5] checkboxes for ratings 1 - 5; One of the text field is accompanied with a dropdown list option (searchby: title or director or description); The other two text fields are for input of dates, hence it will be blank ( yyyy/mm/dd to yyyy/mm/dd).
What's wrong? Question
if (!empty($_POST["searchby_title"]))
$conditions[] = "`title` LIKE '" . mysql_real_escape_string($_POST["searchby_title"]) . "'";
f (!empty($_POST["searchby_Director"]))
$conditions[] = "`Director` LIKE '" . mysql_real_escape_string($_POST["searchby_Director"]) . "'";if (!empty($_POST["searchby_Description"]))
$conditions[] = "`Description` LIKE '" . mysql_real_escape_string($_POST["searchby_Description"]) . "'";
if (!empty($_POST["Release_date"]))
$conditions[] = "`Release_date` >= '" . mysql_real_escape_string($_POST["Release_date"]) . "'";
if (!empty($_POST["Release_date2"]))
$conditions[] = "`Release_date` <= '" . mysql_real_escape_string($_POST["Release_date2"]) . "'";
// checkbox
if (isset($_POST["rating"])) $conditions[] = "`rating`";
if (isset($_POST["rating"])) $conditions[] = "`rating`";
if (isset($_POST["rating"])) $conditions[] = "`rating`";
if (isset($_POST["rating"])) $conditions[] = "`rating`";
if (isset($_POST["rating"])) $conditions[] = "`rating`";
The best advice I can give you is to echo out your query once it is completely created. You will then be able to see where the error in the query is coming from. You should also report the mysql error with mysql_error() to give you some additional information.
Also, I'm not sure why you have the following line repeated:
if (isset($_POST["rating"])) $conditions[] = "`rating`";
you might want to take a look at that, also.