vijdev Posted September 21, 2010 Share Posted September 21, 2010 "vijdev and 0 Guests are viewing this topic." can someone help me with a pointer on how to get started with something like the above message when viewing different pages in the site...it must be page/topic specific. is this using sessions/cookies/databases?...? Quote Link to comment Share on other sites More sharing options...
chintansshah Posted September 21, 2010 Share Posted September 21, 2010 You can do this using Database. Whenever user click on particular page, increase clicks column by +1 Quote Link to comment Share on other sites More sharing options...
vijdev Posted September 21, 2010 Author Share Posted September 21, 2010 well, that would give me a hit count, how can i display current users? Quote Link to comment Share on other sites More sharing options...
vijdev Posted September 22, 2010 Author Share Posted September 22, 2010 Anyone? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 22, 2010 Share Posted September 22, 2010 There are a ton of 'who is online' scripts posted all over the internet. You use a database table. Anytime someone navigates to a page you insert/update a record for them in the table. If that person is logged in, as determined by your login code, you enter their username. If that person is not logged in, you enter them as a non-logged in guest. You can keep track of each guest by using the same kind of session that you are using for your logged in members, but save a value indicating the 'guest' status. To display the values you simply get a list of the logged in usernames and count the 'guest' records from the table. Quote Link to comment Share on other sites More sharing options...
dreamwest Posted September 22, 2010 Share Posted September 22, 2010 $ip = $_SERVER['REMOTE_ADDR']; if($ip){ $res = mysql_query("select from table where ip='{$ip}' limit 1"); //ip is varchar 255 if($res){ $num = mysql_num_rows($res); if($num == 0){ mysql_query("insert into table set ip='{$ip}' "); }//end if num }//end if res }//end if ip Run cron to delete ips every 5 mins or so, then just count the rows ..and they lived happily ever after.. The end Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted September 22, 2010 Share Posted September 22, 2010 $ip = $_SERVER['REMOTE_ADDR']; if($ip){ $res = mysql_query("select from table where ip='{$ip}' limit 1"); //ip is varchar 255 if($res){ $num = mysql_num_rows($res); if($num == 0){ mysql_query("insert into table set ip='{$ip}' "); }//end if num }//end if res }//end if ip Run cron to delete ips every 5 mins or so, then just count the rows ..and they lived happily ever after.. The end or instead of cron you can store a timestamp and match that against the current time, deleting any entries older than 5mins or whatever. Quote Link to comment Share on other sites More sharing options...
vijdev Posted September 23, 2010 Author Share Posted September 23, 2010 ok, great! Quote Link to comment Share on other sites More sharing options...
dreamwest Posted September 24, 2010 Share Posted September 24, 2010 $ip = $_SERVER['REMOTE_ADDR']; if($ip){ $res = mysql_query("select from table where ip='{$ip}' limit 1"); //ip is varchar 255 if($res){ $num = mysql_num_rows($res); if($num == 0){ mysql_query("insert into table set ip='{$ip}' "); }//end if num }//end if res }//end if ip Run cron to delete ips every 5 mins or so, then just count the rows ..and they lived happily ever after.. The end or instead of cron you can store a timestamp and match that against the current time, deleting any entries older than 5mins or whatever. You still need cron for that too. I wouldnt recommend deleting rows every time a page is called, thats bad and expensive Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.