Re: Pulling an ID list from a DB, then filtering thatlist againstanother list of ID's

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here is what I have for a layout:

thing_id -> it is a hash value (md5())

I have a user session variable that is an array "thing_id's that were
viewed".

So each time the user click a like to view a thing_id, I note that in a
session variable, so when they go back to the home page, all the things
they have viewed are not shown, only the ones they have not viewed.

Thing_id
---------
1 | hash_id_1
2 | hash_id_2
3 | hash_id_3
4 | hash_id_4

Viewed (Session Var)
--------------------
1 | hash_id_2
2 | hash_id_4


So when the user hits the homepage, they should get a list of 2 hash
ID's hash_id_1 and hash_id_3. That is how I want this to work, I just
need a slick way to compare and filter the viewed hash_id's from the
complete list I am pulling form the DB.

Does that help?

Thanks,
Matt

On Thu, 2003-08-14 at 16:35, CPT John W. Holmes wrote:
> From: "Matt Babineau" <matt@criticalcode.com>
> > Got an interesting problem! I have a list of ID's, basically  things
> > people have viewed on my website. When I pull the viewable items from my
> > database, I need to be able to filter out all the ID's people have
> > already viewed, so that they only get a list of things they have not
> > viewed.
> >
> > I can think of a way to do this, but it is a nasty loop situation, that
> > would probably not be good and tie up significant CPU time. Anyone have
> > any suggestions on ways to filter view items from a fresh list that I am
> > pulling from my Database?
> 
> So you have a "thing_id" and a "user_id". How do you mark the user as having
> viewed the "thing"?
> 
> I'm thinking a LEFT JOIN is in order here, but need some more info on your
> table structure.
> 
> ---John Holmes...
> 


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux