php - CodeIgniter/MySQL - select, where not equal to and like twice -


i having problems returning correct records when using following active record query in codeigniter:

$q = $this->db->query("select fname, lname, userid                         user                         userid !='$user_id'                        , fname '%$search_criteria%'                         or lname '%$search_criteria%'");  

the query searches users table based on $search_criteria. $user_id id of logged in user don't appear in search results.

if search logged in users first name doesn't return logged in user in search results, return logged in user if search last name, don't understand why...

there flaw in logic, want check user id, , check either first name or last name... did here userid , fname or lname. parens separate criteria, allowing either fname or lname id

$q = $this->db->query("select fname, lname, userid                         user                         userid !='$user_id'                        , (fname '%$search_criteria%'                         or lname '%$search_criteria%'"));  

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -