This is my model code:
public function GetId() { $this->db->select('count(*) as total'); $this->db->from($this->table); $this->db->where('dibaca', null); $query = $this->db->get(); return $query->result_array(); }
This is my html code:
<?= $DataId['total']; ?>
I have called the function as DataId to my controller, I get the error, undefined array key 'total'
Can you tell me what's wrong?
Replace result_array() in the model with
You can remove ['total'] from the html code, or like this:
Some untested suggestions:
Your model can be refined into:
Your controller should call the model data and pass it to the view.
Finally, your view can access the variables associated with the first-level keys in the passed array.
This is a related post that covers passing data from a controller to a view.