How to get related posts using PHP and MySQL

qwehtipyvx

New Member
What is the best way to get related posts using PHP and MySQL? The second question is how would I get the top 5 related posts from by comparing tags and categories from each post. My MySql tables are listed below.\[code\]CREATE TABLE categories ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, parent_id INT UNSIGNED NOT NULL DEFAULT 0, category VARCHAR(255) NOT NULL, url VARCHAR(255) NOT NULL,PRIMARY KEY (id), INDEX parent (parent_id),UNIQUE KEY(parent_id, url));CREATE TABLE posts_tags (id INT UNSIGNED NOT NULL AUTO_INCREMENT,tag_id INT UNSIGNED NOT NULL,users_posts_id INT UNSIGNED NOT NULL,PRIMARY KEY (id));CREATE TABLE tags (id INT UNSIGNED NOT NULL AUTO_INCREMENT,tag VARCHAR(255) NOT NULL,PRIMARY KEY (id));CREATE TABLE users_posts (id INT UNSIGNED NOT NULL AUTO_INCREMENT,user_id INT UNSIGNED NOT NULL,title TEXT NOT NULL,posts_content LONGTEXT NOT NULL,PRIMARY KEY (id));\[/code\]
 
Back
Top