[eluser]Unknown[/eluser]
Hi there
I'm rather new to php and even newer to Codeigniter. I'm building a site and I ran into a snag.
My users table has a field called "role_id". This is a foreign key from a table "roles" which has just 2 fields (id and role). My problem is that when a user is created, they must select their role from a dropdown menu. I can get their role (the actual name "boss" or "grunt") but I need to get the id of that role from the table "roles", and that I know not how to do.
I use this for getting the actual role
Code:
$role = $this->input->post('role');
Tried this for the ID but it doesnt work
Code:
$q = "SELECT id FROM roles WHERE role = ".$role."";
$role_id = $this->db->query($q);
This all happens in my Users_model.