RE: [PHP] online/offline...but on a list of users
| From: | Shaw, Chris - Accenture | Date: | Mon, 05 Sep 2005 08:23:06 +0000 |
| Subject: | RE: [PHP] online/offline...but on a list of users | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-221853@lists.php.net to get a copy of this message | ||
> <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.
>
What about using the 'in' or 'exists' keyword in sql.
for example:
select * from (select username from <the rest of your online select
statement>) a
where a.username in ($username, $username, $username ..)
Use some for loop to build up your 'in' statement.
A better way to do it is using joins and the exists statement, but its too
early for that. :)
************************
This message has been delivered to the Internet by the Revenue Internet e-mail service
*************************