php codeigniter count rows
问题 I am new in codeigniter, I want to count all rows from database table but the query dose not retrieve the exact total of rows. Here is Model public function countRow(){ $query = $this->db->query("SELECT *,count(id) AS num_of_time FROM home"); // print_r($query->result()); return $query->result(); } and this is the controller public function countTotalrow(){ $data['query'] = $this->home_model->countRow(); } this is the view foreach ($num_of_time as $row){ <span><?php print_r($row->id);?></span