erinod Posted October 6, 2011 Share Posted October 6, 2011 Hi all, I'm trying to get a search box and a checkbox to both work at the same time. I have two versions of this code, when I use the first one my checkbox works like it should, filtering out all records with product_type = 3, but the search bar no longer works as it should, filtering things out of three fields defined elsewhere. The bottom code has the search bar working but doesnt incorporate the checkbox as a filter. Thanks for any help! Checkbox works: $where_filter = ""; if($where != "*"){ foreach($search_map as $search_name){ $where_filter .=" $op $search_name $not REGEXP '$where'"; } $where_filter = substr($where_filter, 5)." AND "; } if ($exclude == "exclude"){ $where_filter .= "product_type!='3'"; $q->addWhere("($where_filter)"); $q->addOrder('product_id'); } Search works: $where_filter = " "; foreach($search_map as $search_name) $where_filter .=" $op $search_name $not REGEXP '$where'"; $where_filter = substr($where_filter, 5); if($where != "*") $q->addWhere("($where_filter)"); $q->addOrder('product_id'); Quote Link to comment https://forums.phpfreaks.com/topic/248572-problem-with-php-and-sql-search-need-to-combine-these-two-code-blocks/ Share on other sites More sharing options...
erinod Posted October 6, 2011 Author Share Posted October 6, 2011 update: update: actually what is happening is the search box is only working when the checkbox is checked too Quote Link to comment https://forums.phpfreaks.com/topic/248572-problem-with-php-and-sql-search-need-to-combine-these-two-code-blocks/#findComment-1276594 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.