Jump to content

problem with php and sql search, need to combine these two code blocks


erinod

Recommended Posts

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');

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.