3
我有一些主類別和用戶組,用戶組被分配到主類別。我正在使用下面的代碼,但它只顯示錶中的最後一條記錄,而我需要顯示所有匹配的記錄。對於每個循環無法正常工作
功能的控制器:
function listdesignation($id) {
$res = $this->designation_model->GetDesignation($id);
$this->data['test'] = $res;
if ($res) {
foreach ($res as $row) {
$this->data['selected_designation'] = $this->designation_model->GetDesignation_Names($row['designation_id']);
}
if ($this->data['selected_designation']) {
$this->data['enable_view'] = true;
}
}
}
功能模型:
function GetDesignation_Names($id) {
$designation = array();
$this->db->select('*');
$this->db->from('delta_designation');
$this->db->where('designation_id', $id);
$query = $this->db->get();
if ($query->num_rows() > 0) {
foreach ($query->result() as $row) {
$designation[$row->designation_id]['designation_id'] = $row->designation_id;
$designation[$row->designation_id]['designation'] = $row->designation;
}
return $designation;
}
return false;
}