My Question is, how do I compare a group of tags to another posts tags in my database to get related posts?
To start off, I've searched the internet and stackoverflow to find out how to do this. My closest find was this post http://stackoverflow.com/questions/2153062/how-to-find-related-items-in-php. But it actually doesn't solve much for me.
What I'm trying to do is compare a group of tags on a post to another post's tags, but not each tag individually. So say you wanted to get truly related items based on tags from a post and then show them from the most related to the least related. Each time there has to be 3 related items shown though no matter the relationship level.
Post A has the tags: "architecture", "wood", "modern", "switzerland"
Post B has the tags: "architecture", "wood", "modern"
Post C has the tags: "architecture", "modern", "stone"
Post D has the tags: "architecture", "house", "residence"
Post B is related to post A by 75% (3 related tags)
Post C is related to post A by 50% (2 related tags)
Post D is related to post A by 25% (1 related tag)
How can I do that? I'm currently using a 3-tables.
posts
> id
> image
> date
post_tags
> post_id
> tag_id
tags
> id
> name