我只是 Codeigniter 的新手。我想在视图页面中显示这个 SQL 查询的 bill_rpt 的总和。这是代码
这是我的模特
public function total() {
$sql="SELECT bill_rpt
FROM amilyar_bill
WHERE bill_status = 1";
return $this->db->query($sql);
}
这是我的控制器
public function payments($token=''){
$this->isLoggedIn();
$data = array(
// get data using email
'token' => $token,
'admin_info' => $this->model->getAdminInfo($this->session->userdata('email'))->row(),
'notifications' => $this->model->notification_admin($this->session->userdata('email'))->result_array(),
'notification' => $this->model->all_notification_admin($this->session->userdata('email'))->result_array(),
'total' => $this->model->total($this->session->userdata('email'))->result_array(),
);
if ($this->session->userdata('position_id') == 2) {
$this->load->view('includes/admin_header',$data);
$this->load->view('admin/reports/payments',$data);
} else {
$this->logout();
}
}
这是我的观点
<h4 class="pull-right">Total:</h4>
提前致谢