James Thompson James Thompson - 3 months ago 5
SQL Question

How to display total users on dashboard

I have this CI project in which sometimes I need to manage get the all users from database to display on my dashboard at backend. for example (TOTAL USERS? - 10 )

the users from database should be induce admin, editors, members etc


In your Users model you should put something like this :

public function get_UserNumber(){   

    $this->db->select("count(*) as no");                        
    $query = $this->db->get("users");          
    return $query->result();            


Dashboard controller should include these lines of code :

    $usersNo =  $this->users_model->get_UserNumber();   
    $data['totalUsersNo'] = $usersNo[0]->no;

And of course in your Dashboard view :

    <?php echo $totalUsersNo; ?>

Voila ... hope that helped !!!