so here is my model codes:
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();
}
and this is my code in html:
<?= $DataId['total']; ?>
i already call the function to my controller as DataId, and i get error that Undefined array key "total"
can you guys tell me what is wrong in it?
getId()is a poor name for a method that returns a count.result_array()returns and whatrow_array()returns. Either tryrow_array()in the model,$DataId[0]['total']in the view, or clean up everything with the advice in my answer.