Re: [PHP] online/offline...but on a list of users
Ryan A wrote: clip I want to add this same functionality to a forum on the same site (the forum was custom programmed from scratch and not any of the popular ones), but since in a single thread there can be a lot of different people/usernames that answer I would prefer _not_ to do a select lookup for each username... any ideas on how else it can be done? /clip I'd say start with a query that pulls the online users into an array, then do an array_key_exists() or in_array() against that. Thanks! Thats a really good idea and one that i didnt think of. For now it should be okay as there are just a few hundred users, but if it gets really big then it might be a bit of a problem... if you any other ideas please feel free to reply till then I'll try your idea out. Thanks, Ryan One of the things to think about with this is, although you may have a few hundred users signed up how many are online at once. I've got a forum with a few thousand members, but at any one time there's only about 15 average that are online. It peaks at about 45 sometimes, but that's rare. So the array in this case is relativly small. Plus it lets you do other things with the infomation like There are X users online, showing who is reading what and stuff like that. If your running a site like MySpace or DA then it could be a problem. They tend to break things down though into smaller groups like showing your friends, or whatever they call them, that are online. Another idea that goes with what Chris had said is to use a join on your online table. I'm assuming that your having to do a lookup for each post in the forum anyway, just join the online table here against the members id or name or whatever your using to track who makes the individual posts. How you do it exactly really depends on how you're building up the forums page. That would probably be a better situation all around if you're doing a query for each post anyway. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] online/offline...but on a list of users
Hi, I have a profiles page where next to the username I have a icon that says Online or Offline if the persons whose profile you are browsing signed in or clicked anything in the last 3 minutes (I am also using a meta refresh to call a script every 2 1/2 mins) this is how i am doing it: $check_if_member_online=select NOW() DATE_ADD( last_online, INTERVAL 3 MINUTE ) as j_is_online FROM `.$prefix.members_online` WHERE cno ='.$jno.' and member_name='.$username.' LIMIT 1; This is the table it calls _members_online ( cno bigint(20) NOT NULL default '0', member_name varchar(30) default NULL, last_online datetime default NULL, KEY member_name (member_name), KEY cno (cno), ) and its working fine. I want to add this same functionality to a forum on the same site (the forum was custom programmed from scratch and not any of the popular ones), but since in a single thread there can be a lot of different people/usernames that answer I would prefer _not_ to do a select lookup for each username... any ideas on how else it can be done? Thanks, Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] online/offline...but on a list of users
Ryan A wrote: Hi, I have a profiles page where next to the username I have a icon that says Online or Offline if the persons whose profile you are browsing signed in or clicked anything in the last 3 minutes (I am also using a meta refresh to call a script every 2 1/2 mins) this is how i am doing it: $check_if_member_online=select NOW() DATE_ADD( last_online, INTERVAL 3 MINUTE ) as j_is_online FROM `.$prefix.members_online` WHERE cno ='.$jno.' and member_name='.$username.' LIMIT 1; This is the table it calls _members_online ( cno bigint(20) NOT NULL default '0', member_name varchar(30) default NULL, last_online datetime default NULL, KEY member_name (member_name), KEY cno (cno), ) and its working fine. I want to add this same functionality to a forum on the same site (the forum was custom programmed from scratch and not any of the popular ones), but since in a single thread there can be a lot of different people/usernames that answer I would prefer _not_ to do a select lookup for each username... any ideas on how else it can be done? Thanks, Ryan I'd say start with a query that pulls the online users into an array, then do an array_key_exists() or in_array() against that. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] online/offline...but on a list of users
clip I want to add this same functionality to a forum on the same site (the forum was custom programmed from scratch and not any of the popular ones), but since in a single thread there can be a lot of different people/usernames that answer I would prefer _not_ to do a select lookup for each username... any ideas on how else it can be done? /clip I'd say start with a query that pulls the online users into an array, then do an array_key_exists() or in_array() against that. Thanks! Thats a really good idea and one that i didnt think of. For now it should be okay as there are just a few hundred users, but if it gets really big then it might be a bit of a problem... if you any other ideas please feel free to reply till then I'll try your idea out. Thanks, Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php