Jump to content

How Do I Create Categories For A Blog Post?


signature16

Recommended Posts

I created a very simple shoutbox.  User posts their name and a message and clicks post.  It posts to the database and when the page reloads, the "shout" is displayed.

 

I would like to add categories to this little shoutbox application I created.  The user should be able to check off boxes to apply different categories to a post.  For example a shout could be in the categories, php,mysql,html and css.

 

 

Logistically how do I do this using MySQL and PHP?  ... Obviously this is just a project for learning and has no real application.

 

Thanks.

Link to comment
Share on other sites

there is about a million ways to do this.

1 make a static array in php

2 make an mysql table of them and query them

3 make a mysql table and then use an enum field for optimized storage

4 make the second mysql table store then as integers in the new one and use a psedo enum on output.

 

5-1million any varieation on the above or what ever you like

Link to comment
Share on other sites

Ok lets say I am going to go with option 2... or at least definitely not option 1.

 

Do I create two tables? 

.... one for the posts (id,title,categories,message) and one for the categories (id,category,description)?

 

 

This is where I get confused. 

 

 

Once I have two tables what do I do?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.