TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   how do you do a automatic status print on website like this (http://www.talkphp.com/general/3524-how-do-you-do-automatic-status-print-website-like.html)

codefreek 10-25-2008 05:17 AM

how do you do a automatic status print on website like this
 
Hello ;)
how do you do a automatic status print on website like this,

70 Users visited site in the past 24 hours
Users Online 1 || Guest(s) online.32 || Total Online 33
website.com has 10816 members... and growing!



:-$

Tanax 10-25-2008 02:49 PM

Users online:
PHP Code:

        public function get_users_online() {
            
            
$sql "    SELECT
                            `"
.$this->db->col['user_id']."`,
                            `"
.$this->db->col['user_name']."`,
                            `"
.$this->db->col['user_access']."`
                        FROM
                            `"
.$this->db->table['users']."`
                        WHERE
                            `"
.$this->db->col['user_session']."` != ''";
                            
            
$query $this->db->query($sql) or die(mysql_error());
            
            if(
mysql_num_rows($query)) {
                
                
$i 0;
                
                while(
$row $this->db->fetch($query)) {
                    
                    
$this->users[$i]['user_id'] = $row['user_id'];
                    
$this->users[$i]['user_name'] = $row['user_name'];
                    
$this->users[$i]['user_access'] = $row['user_access'];
                    
                    
$i++;
                    
                }
                
                return 
$this->users;
                
            }
            
            return 
false;
            
        } 

Total members:
PHP Code:

        public function get_users_registered() {
            
            
$sql sprintf("    SELECT
                                    *
                                FROM
                                    `%s`"
,
                                    
                                
$this->db->table['users']);
                                
            
$query $this->db->query($sql);
            
            if(
mysql_num_rows($query)) {
                
                
$users = array();
                
$i 0;
                
                while(
$row $this->db->fetch($query)) {
                    
                    
$users[$i]['user_id'] = $row['user_id'];
                    
$users[$i]['user_name'] = $row['user_name'];
                    
$users[$i]['user_last_visit'] = $row['user_last_visit'];
                    
$users[$i]['user_email'] = $row['user_email'];
                    
$users[$i]['user_age'] = $row['user_age'];
                    
$users[$i]['user_country'] = $row['user_country'];
                    
$users[$i]['user_access'] = $row['user_access'];
                    
$users[$i]['user_session'] = $row['user_session'];
                    
                    
$i++;
                    
                }
                
                return 
$users;
                
            }
            
            return 
false;
            
        } 

Edit: This is ofcourse using sessions.. but you should be able to "translate" this to however you would want it if you're not using sessions

I haven't a function for user visitors.. and guests I'm not sure either..

Wildhoney 10-25-2008 04:43 PM

It's just a case of saving the data into a table, with a corresponding timestamp. You can then easily select from there, and also select where timestamp is over 24 hours ago, 5 minutes ago, etcetera.


All times are GMT. The time now is 10:57 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0