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
Post a Comment