CodeIgniter Forums
About All Members Count? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: About All Members Count? (/showthread.php?tid=73423)



About All Members Count? - Qortizon - 04-22-2019

Hi,

How can I make show the total number of members registered in Codeigniter?

Model? Controller? View?


RE: About All Members Count? - php_rocs - 04-22-2019

@Qortizon,

You could create a model that gets the total number of members registered in Codeigniter and pass the result to the controller which passes it to the view. You could also, get the total number of members when a user first logs into the system and save the value in a session variable and call it as necessary in a controller which would make it available in any view.


RE: About All Members Count? - ciadmin - 04-22-2019

If you are talking about the number of registered members on the forum, that is shown in the "forum statistics" panel down the left side of the "Home" (portal) navbar link on the forum. Your intent is not clear from your question.

There are good arguments for that being in a model (retrieving data), or in a library (since you might actually model the data or data source), and a weaker one for having it in a controller (retrieving and processing the contents of a page), but I can think of no good arguments for retrieving such data in a view.


RE: About All Members Count? - Qortizon - 04-23-2019

Thansk for your answers.

I'm new in codeigniter.

Model:

Code:
public function get(){
      $this->db->select('gorun');
      $this->db->from('users');
      $this->db->where('gorun', '0' );
      return $this->db->count_all_results();
}

-------------------------

Controller:

Code:
public function admindash(){
      $this->load->model("admindash_model");    
      $results = $this->admindash_model->get();
}



I can't show the view. How can I do it?