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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.