Forums / General / People who bought this... but with articles

People who bought this... but with articles

Author Message

Jorge estévez

Tuesday 05 October 2004 9:37:02 pm

Hi!

People who bought this also bought... Can I do something similar with articles? I would like to implement something like: People who saw this article also saw:

1-xx
2.-yy
and so on...

Ho can an object relation be implemented in this manner, knowing the relation on people who saw the same article the user is in and the related articles that they also visited... (rather confusing, hope you get the idea)

thanks

Diseño Web Cuba
Web Design Cuba
www.elfosdesign.com

Gunnstein Lye

Monday 11 October 2004 4:37:18 am

This must be implemented on a low level, probably in index.php, because articles are usually cached. You could make an SQL table with two columns, user id and object id, and whenever someone views an object you can detect this in index.php and store the information in the table. When you need the information, run some queries like this:

X is the object id of the object in question.
First, fetch all users who has viewed this object:

select user_id from user_object_read_table where object_id = X;

For each user, fetch his object ids:

select object_id from user_object_read_table where user_id = 42;

Then you have a list of all objects this users has viewed. Do this for all the users, concatenate the results, and return the object ids that are most common.
This will be somewhat slow on a medium to large site, so you might want to do it in a daily cronjob.