1

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'] = 'report_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

1 Answer 1

1

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; ?>
Sign up to request clarification or add additional context in comments.

1 Comment

Glad I could help... I don't use codeigniter myself so I wasn't 100% sure that would do the trick :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.