SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot JordanTLClive's Avatar
    Join Date
    Feb 2001
    Location
    Las Vegas, NV
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am trying to setup a news system that will allow members to enter news stories for one or more categories. I have setup tables as follows but want to know how I would go about listing news stories in multiple categories?

    News table
    int id, text newstext, date newsdate, int catid, int genreid, int aid
    id is the unique identifier, newstext is the text of the news, newsdate is the date it was posted, catid is the colum that relates to the category table for the categories each post belongs to, genre id is like catid but for music genres, and aid relates to an author table for authors names, emails, etc.

    Newscat table
    int id, varchar(100) cat
    id is the unique identifier, and cat is the category name. this is the table that relates to catid in the News table.

    Thanks much!
    -Jordan

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2001
    Location
    Rawalpindi, Pakistan
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That depends on database u r using, if not mysql then u can use subquery like this

    select * from News where catid in (select id from Newscat where **any condition to restrict categories** )



    But if mysql then (correct me if I am wrong), more than one recordset...

    Thanx
    Aatif Malik

  3. #3
    SitePoint Wizard westmich's Avatar
    Join Date
    Mar 2000
    Location
    Muskegon, MI
    Posts
    2,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Like the category column, you should have a seperate table for genre. The genre will need an ID, a title, and a description at the least.
    Westmich
    Smart Web Solutions for Smart Clients
    http://www.mindscapecreative.com

  4. #4
    SitePoint Zealot JordanTLClive's Avatar
    Join Date
    Feb 2001
    Location
    Las Vegas, NV
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh the genre and author colums both have seperate tables i just didnt bother to explain those columns more because they didnt pertain to the question
    -Jordan


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •