g23armani Posted April 13, 2006 Share Posted April 13, 2006 I'm working on a portion of my site that allows people to search through a series of articles. I want to sort the articles by category. The problem is, most articles can be placed into more than one category. For example, if I write an article: "Rock Climbing Techniques to Prevent Injury and Increase Strength" I would want this article to be coded under:Rock ClimbingInjury PreventionStrength TrainingWhile I could manually place the article in each of it's categories, I'm sure there is a simple way to use PHP and MySQL to assign multiple categories to each article and then have these articles pulled if someone clicks on the appropriate category or searches for the right keyword.If anyone knows of a good website, book, free code or script source etc that they could point me to that would be tremendously helpful.Thanks!Peter Quote Link to comment Share on other sites More sharing options...
Barand Posted April 13, 2006 Share Posted April 13, 2006 Whenever you have a situation like yours where1 book can belong to many categories1 category can contain many booksyou have what is known as a "many-to-many" relationship.To resolve this you create an intermediate link table "article_category", for instance.Category----------1 | Rock Climbing2 | Injury Prevention3 | Strength TrainingArticle-------------1 | Rock Climbing Techniques to Prevent Injury and Increase Strength2 | Climbing for DummiesArticle_category---------------------catid | articleid 1 | 1 2 | 1 3 | 1 1 | 2 Quote Link to comment Share on other sites More sharing options...
g23armani Posted April 14, 2006 Author Share Posted April 14, 2006 Thanks, that should help quite a bit. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.