I have two tables: Company & Users.
I have a form in which i insert Company name and others details. in that same form i have a sub form Sales info and Tech info.
The data i insert in sales and tech info gets stored into users tables.and their id are stored into company table in two fields called sales_id and tech_id.
Now for a view i want to fetch company name its sales person and its tech person,How to do it?
The Code in model:
public function get_company()
$this->db->join('users','users.id = company.sales_id','users.id = company.tech_id');
$query = $this->db->get();
$result = $query->result();
IN The View:
<?php if(count($companys)): foreach($companys as $company): ?>
<td><?php echo $company->first_name; ?></td>
how to differentiate which is sales and which is tech person?
public function add_company($id = NULL)
$this->data['company'] = $this->company_m->get_new();
$this->data['user'] = $this->user_m->get_new();
$rules = $this->company_m->rules_admin;
if ($this->form_validation->run() == TRUE)
/*Inserting Sales Person Information*/
$data['first_name'] = $this->input->post('first_name_s');
$data['last_name'] = $this->input->post('last_name_s');
$data['email'] = $this->input->post('email_s');
$sales_id = $this->db->insert_id();
/*Inserting Tech Person Info