how can i create a tagging system using php and mysql? how can i create a tagging system using php and mysql? php php

how can i create a tagging system using php and mysql?


You're describing a many-to-many relationship between Articles and Tags. You'd want to use an intermediate junction table to resolve that relationship.

enter image description here

Now, to find all articles that match a selected tag:

SELECT a.article_title    FROM Tag t        INNER JOIN Article_Tag_Xref atx            ON t.tag_id = atx.tag_id        INNER JOIN Article a            ON atx.article_id = a.article_id    WHERE t.tag_name = 'SelectedTagName'


tbl_articles has articleID, etc.

tbl_tags has tagID, etc.

tbl_taggedarticles has taggedArticleID, articleID, tagID

SELECT articleID FROM tbl_taggedarticles WHERE tagID = "searchedID"