I’m not sure why this code isn’t working, so any help would be appreciated.
I want to search for a users username and also show the name of their character, which is store in the profile table.
$search = $_POST['search'];
$this->db->join('user_profiles', 'user_profiles.id = users.id');
$this->db->like('username',$search);
$this->db->or_like('user_profiles.character_name',$search);
$data['users'] = $this->db->get('users');
The page seems to fire fine without any errors, but no matter what I type into the search I get 0 results.
Solved: Nothing wrong with code, it was my form validation.
I suggest that you run the following after your
$this->db->get()This will allow you to debug your query which is being run. This will highlight problems with input criteria and the query itself.