开发者

Programming a Tags Feature in PHP

开发者 https://www.devze.com 2023-04-13 09:42 出处:网络
How would I go about writing up a basic tags feature? (similar to the one on this site) I\'m struggling coming up with good logic with little redundancy and would like a more experienced programmer\'

How would I go about writing up a basic tags feature? (similar to the one on this site)

I'm struggling coming up with good logic with little redundancy and would like a more experienced programmer's take on this.

The site I have is fully developed as of right now and has a search feature (searches through titles) - I'm just looking to expand on this and allow the search to sift through tags 开发者_高级运维as well.

Edit:

I was considering adding a row on to my main table called "tags". Then separating them by spaces.

But I have also thought about create a new table and using the same id's from my main table, creating tags in this manner.


I'd suggest 2 tables. One contains Tags - the name of the tag, a tag id, any anything else you want to keep track of on a tag. Also create a relationship table that connects your article/post id to the tag id. You won't repeat data in the database, you should be able to search the tags and join tables together to come up to return articles, and also query the tags if you want to display them along with posts.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号