Get sum of mysql fields and passing sum to view in codeigniter -


i not able display sum of mysql fields in view. sum-field named urls. instead of displaying sum of urls specific user receive string named 'array'. believe passing problem rather query 1 don't it. thank help.

model (users_model):

public function get_sum($id){     $this->db->select_sum('urls')             ->where('user_id', $id);     $query = $this->db->get('user_earnings');     return $query->result(); } 

controller (users):

public function userarea() {     $id = $this->session->userdata('id');     $data['sum'] = $this->users_model->get_sum($id);     $data['main_content'] = 'userarea_view';     $this->load->view('layout', $data); } 

view (userarea_view):

<li>total urls collected: <br><strong><?php echo $sum; ?></strong></li> 

try like

<?php echo $sum[0]->urls; ?> 

since returned object.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -