Welcome Guest, Not a member yet? Register   Sign In
search feature
#1

[eluser]Bianca Migueis[/eluser]
I'm trying to make a search feature for my site and i'd like to check the user input against different fields of the same table. also i'd like to have more than 1 input value like "Imaginary ln CA" and then check that against my fields. i managed to do that for 1 value so if i type "imaginary" or "ca" it shows the right results. but if i type "imaginary CA" it doesnt show anything =/

code for my search function:

Code:
function search()
    {
        $uri = $this->uri->segment(2);
        $n = 0;
            while (!empty($uri))
            {
                $n += 1;
                if (strpos($uri, ' ') === false){
                    $param[$n] = strtoupper($uri);
                    $uri = null;
                }
                else
                {
                    $pos = strpos($uri, ' ');
                    $param[$n] = strtoupper(substr($uri, 0, $pos));
                    $uri = substr($uri, $pos);
                }
            }
            
            while ($n > 0)
            {
                $this->db->like('UPPER(address)', $param[$n]);
                $this->db->or_like('UPPER(city)', $param[$n]);
                $this->db->or_like('UPPER(description)', $param[$n]);
                $n -= 1;
            }
            
            return $this->db->get('property');
    }




Theme © iAndrew 2016 - Forum software by © MyBB