Alright, Im trying to count all the rows where "Membership_Status" = Active. The result I get right now is "Array" instead of a number.
Here is my model
class Report_model extends Model { function count_members() { $query = $this->db->get_where('Membership', array('Membership_Status' => 'Active')); return $query->num_rows(); } }
Here is my controller
class Report extends Controller { function YTD_report() { $data['main_content'] = 're开发者_高级运维port_membership_view'; $this->load->view('includes/template', $data); } }
Here is my view
report_model->count_members(); echo $total; ?>
My result is Array, where according to the db info, it should be 4.
What can I do/change to get it to display the proper number?
thanks
the $data array your passing to the view will create one variable for each key to be used by view...
So your controler once the model is loaded, you should do:
$data['total'] = $this->Report_model->count_members();
Then in the view you can use the $total variable like this:
<?php echo $total; ?>
精彩评论