This is my function to count messages that (contactus_status = no)
function message_count(){
$this->db->select('*')->from('tbl_contactus')->where('contactus_status', no);
$q = $this->db->get();
return $q->num_rows();
}
How do I display the raw count in the view using this function. Help me
You should start from the basics.
you need to do by this way :
$data['num_count']=$this->your_model_name->message_count();
$this->load->view('your_view', $data);
and in your_view u need to echo $num_count
;
Data(add your count to this variable) is passed from the controller to the view by way of an array or an object in the second parameter of the view loading function. Here is an example using an array:
$data = array(
'title' => 'My Title',
'heading' => 'My Heading',
'message' => 'My Message'
);
$this->load->view('yourview', $data);
for more have look this