0

I'm setting up a PHP function to return a result from the database based on what the user is looking for by a search bar.

In the database I have this: "skirt blue red"

In search bar, if the user writes "skirt red" the result should come out, as "like '%skirt%red%'"

I am trying in this way but it doesn't work.

    if (isset($conds['searchterm'])) {
                $search1 = explode(" ", ($conds['searchterm']));
                 { 
        $cond_name1 = $search1[0];
            $cond_name2 = $search1[1];
            $cond_name3 = $search1[2];
            $cond_name4 = $search1[3];
            $cond_name5 = $search1[4];

                    
        $this->db->group_start();
        $this->db->like( 'table.title', $cond_name1 );
        $this->db->and_like( 'table.title', $cond_name2 );
        $this->db->and_like( 'table.title', $cond_name3 );
            $this->db->and_like( 'table.title', $cond_name4 );
            $this->db->and_like( 'table.title', $cond_name5 );
        this->db->group_end();
                }
            }

What is wrong?

Honestly I'm stuck on this.

David S.
  • 671
  • 3
  • 13

0 Answers0