Welcome Guest, Not a member yet? Register   Sign In
Get rows from table where using array - help
#1

[eluser]mikka23[/eluser]
Its quite simple but I dont know how to do it. I have a lookup_skills table and a skills table. I need to get every row from the skills table for each skill_id(from skills_lookup table) is equal to id(id in skill table). This is what I have but it just returns the row for the last skill_id retrieved.

Code:
$this->db->where('uid', $this->uri->segment(3));
        $sk = $this->db->get('lookup_skills');    
        $skills = $sk->row_array();
        
        $this->db->where('id', $skills['skill_id']);
        $data['skillage'] = $this->db->get('skills');

Help appreciated.
#2

[eluser]mikka23[/eluser]
Managed to accomplish the desired result although it doesnt seems like the easiest way:

Code:
$urlid = $this->uri->segment(3);
        $skills = $this->db->query("SELECT id, uid , skill_id FROM lookup_skills WHERE uid = $urlid ");
foreach ($skills->result() as $row)
{
        $this->db->or_where('id =', $row->skill_id);
}
        $data['skillage'] = $this->db->get('skills');




Theme © iAndrew 2016 - Forum software by © MyBB