2014-10-26 62 views
-1

這裏是我的控制器功能從控制器獲取和值以查看

function assignPartner($id){ 

    $data['projects']=$this->admin_model->getProfData($id,'id','project')->result(); 
    $data['partners']=$this->admin_model->getTableData('partner')->result(); 
    $data['budge']=$this->db->query('SELECT SUM(amount) FROM budge WHERE project_id="'.$id.'"')->result(); 
    //print_r($data);exit; 
    $this->load->view('projectheader',$data); 
    $this->load->view('assignpartner',$data); 
    $this->load->view('projectfooter'); 

} 

這是我的看法頁

<?php echo $budge[0]->amount;?> 

回答

2

您需要別名的總和。如果你的var_dump $在您的視圖讓步,你會看到實際的名字 - 應該是搞砸這樣的:

$budge[0]->SUM(amount). 

更改SQL來..

SELECT SUM(amount) AS amount FROM budge WHERE project_id=