开发者

Sites to help me create tag in PHP (like the tags on this site)

I am trying to learn how to create tags in PHP/MySQL. Does anyone know some good sites that help explain how to go about creating tags?

Tags as in the tags you see when yo开发者_Go百科u ask a question in stackoverflow.


A very simple example would be to have three tables:

+---------------------+    +--------------------+    +---------------------+
| Tags                |    | Questions          |    | QuestionTags        |
+---------------------+    +--------------------+    +---------------------+
| + TagID             |    | + QuestionID       |    | + QuestionID        |
+---------------------+    +--------------------+    +---------------------+
| + TagName           |    | + QuestionTitle    |    | + TagID             |
+---------------------+    +--------------------+    +---------------------+
                           | + QuestionText     |
                           +--------------------+

You can have all of your tags within the tags table:

+---+---------+
| 1 | PHP     |
+---+---------+
| 2 | C#      |
+---+---------+

Your questions within your questions table:

+---+-------+---------------------+
| 1 | Tags? | How do I make tags. |
+---+-------+---------------------+

And then associate them in the QuestionsTags table via their ID's:

+---+---+
| 1 | 1 |
+---+---+

This places tag 1 with question 1. You can insert anther row to add another tag to question 1. Now to get all tags for a question, you query the QuestionTag table basing your search on the question ID. To get all questions for a tag, you query the QuestionTag table basing your search on the tag ID.

Good luck!


You might look at this project for inspiration and ideas, http://alexking.org/projects/php-tag-engine


Try this tut out out. It's about creating a blog system that can have none, one, or multi tags. http://net.tutsplus.com/tutorials/php/how-to-create-an-object-oriented-blog-using-php/

Good Luck.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜