[eluser]emuexplosion[/eluser]
This is what I've come up with. It works for what it is right now, I've just got to come up with the code to pull the department names out of the db rather than the id numbers of them. Shouldn't be too hard. Thanks for the help.
Code:
function getStaff()
{
$this->db->select('*');
$this->db->from('staff');
$this->db->join('departments', 'departments.id = staff.department', 'left');
$this->db->orderby('departments.display', 'asc');
$query = $this->db->get();
$dpt='';
$output='';
if ($query->num_rows() > 0) {
foreach ($query->result() as $staff) {
if($dpt != $staff->department)
{
if($dpt!='')
$output .= '</ul>';
$dpt = $staff->department;
$output .= '<h1>'.$dpt.'</h1>';
$output .= '<ul>';
}
$output .= '<li><strong>' . $staff->fname . ' ' . $staff->lname . '</stong></li>';
}
return $output;
} else {
return '<p>Sorry, no results returned.</p>';
}
}