[eluser]toopay[/eluser]
in your model, it should be...
Code:
function check_staff_on_leave()
{
$this->db->select('Department, COUNT(*) AS on_leave', FALSE);
$this->db->from('checkoff');
$this->db->where('Department', $this->input->post('department'));
$this->db->group_by('Department');
$this->db->having('COUNT(*) >', 2);
$result = $this->db->get();
if($result->num_rows() > 0)
{
$rows = $result->result_array();
// Generating query to table 2
$this->db->select('MIN(Date),StaffName,ReportBack');
$this->db->from('appliedleaves');
$this->db->where('Department', $rows[0]['Department']);
$res = $this->db->get();
// This variable should give you matched result from table 2
$result = $res->result_array();
}
else
{
$result = 'No result';
}
return $result;
}
then in your controller, you can use it like
Code:
...
$this->load->model('leave_model');
$data['staff'] = $this->leave_model->check_staff_on_leave();
$this->load->view('some_view',$data);
...
and in your 'some_view' file, you can check the result like...
Code:
...
<?php var_dump($staff); ?>
...