Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder GSimpson's Avatar
    Join Date
    Aug 2006
    Location
    New Zealand
    Posts
    268
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Code Structure Ideas

    Hey there,

    I'm currently building a script of my own that categorizes articles for a blog.
    I've got different categories, they're all stored within a single MYSQL table named 'categories', with three pieces of information each. id, title and parent. (ID is a primary key, title is the category name and parent is if this category is a sub category within another)

    I've got the basic browsing sorted, using URL variables to move up and down the category levels, but the thing I can't work out, is how to display lower level categories articles. I have another table, 'articles' which contains this information 'id, title, content, category'

    Obviously, when browsing the category tree, I can use a mysql_query to display articles marked with the same category as the one being viewed, but I can't find the lower level category articles with the ones within that category.

    If I have these in my categories table:

    id(3), title(Sample3), parent(0)
    id(4), title(Sample4), parent(3)
    id(5), title(Sample5), parent(3)
    id(6), title(Sample6), parent(5)

    So on the link article-list.php?cat=3, with the query I'm doing at the moment, it will show anything from sample4, and sample5, but I don't know how to include blog articles marked with category 6 aswell. Obviously, if I was only browsing category 5, it would show articles from that, and from category 6 too.

    Have I structured my tables wrong to complete the task I'm trying to do? I know they're basic tables, but they're only for example. I would google this, if I knew exactly what it is called.

    Thanks in advance.
    Last edited by GSimpson; 10-22-2009 at 02:02 PM.
    The internet is my Sandbox, and notepad is my Spade n' Bucket.


 

Posting Permissions

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