only1perky Posted February 15, 2009 Share Posted February 15, 2009 Hi Guys I going mad here as I can't get my advanced search working and I don't know why. At the moment I have a search page with a text box and select option and some checkboxes. If I just use the text box and checkboxes it works fine. However when I use the select box and checkboxes it ignores my sql. Here is my code: if($_GET['criteria'] != "" && $_GET['area'] != "") { mysql_select_db($database_connuser, $connuser) or die; $find3 = $_GET['area']; $find = implode("=1 AND ",$_GET['criteria'])."=1"; $query = "select * from table where area like \"%$find3%\" AND ".$find." order by featured desc, venue asc"; Now when I echo the query it completely ignores the first area and goes straight to the checkbox criteria. I know $_GET['area'] is being passed as when I simply search by area alone it works fine. What am I doing wrong? Link to comment https://forums.phpfreaks.com/topic/145273-what-is-wrong-with-this-statement/ Share on other sites More sharing options...
farkewie Posted February 15, 2009 Share Posted February 15, 2009 Hi, Try this <?php $query = "SELECT * FROM table WHERE area LIKE \"%$find3%\" AND area LIKE ".$find." ORDER BY featured DESC, venue ASC"; ?> You had not added a field to compare $find to. I also recommend using UPPERCASE for standard SQL words for ease of reading. Link to comment https://forums.phpfreaks.com/topic/145273-what-is-wrong-with-this-statement/#findComment-762665 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.