[eluser]RobertB.[/eluser]
Hello again guys;
Hopefully someone understand what I'm trying to do.
Trying to get results from the second table based on the results of the first query but this returns only the results from the first table that I don't want. I want to get the results from the second table. Can someone give me a little push
MODEL
Code:
function Function($id)
{
$this->db->select('col1, col2');
$this->db->from('table1');
$this->db->where('id', $id);
$query = $this->db->get();
return $query->row();
$col1 = $query->row('col1');
$col2 = $query->row('col2');
$cols = $col1 + $col2;
$this->db->select('col3');
$this->db->from('table2');
$this->db->where('col3', $cols);
$query = $this->db->get();
if ($query->num_rows() > 0) {
foreach ($query->result() as $row) {
$data[] = $row;
}
return $data;
}
}
CONTROLLER
Code:
function getResults()
{
$id = 1;
$data['result'] = $this->model->function($id);
print_r($data['result']);
}
Thanks.