tags:

views:

187

answers:

3

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 you ask a question in stackoverflow.

+3  A: 

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

Flash84x
+5  A: 

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!

Jonathan Sampson
thank you thank you
ggfan
+1  A: 

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.

Brian Ojeda