I want to display the total number of rows in a table. When I do this following message is displaying in the view, I can't find the mistake in my code. Where is the mistake in the code?
The error that is displayed
A PHP Error was encountered Severity: Notice Message: Undefined variable: data Filename: views/admin_index_view.php Line Number: 15
Model Function
public function count_registerd_customers() {
$query = $this->db->query('SELECT * FROM tbl_customers');
return $query->num_rows();
}
Controller function
public function index() {
$data['registered_customers'] = $this->admin_index_model->count_registerd_customers();
$this->load->view('admin_index_view',$data);
}
On My View
<?php echo $data['registered_customers']; ?>