SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Mar 2001
    Location
    the windy city
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how would you structure this?

    ok,
    this is my first time ever doing anything with server-side stuff.

    the navigation for the site is divided into 5 main categories which have sub-links in them. Clicking on the main category will display the sub-links. the idea is to display teh current category and sub-category in a different color. I could potentially acomplish this with javascript, buti think that in this situation, having it come from a db will be a better approach.

    so my idea was that each link will carry some parameters with it and then i will perform a check and say
    Code:
    if ((category == passed category) && (sub-link = passed sub-link)) {
      display in red
    }
    else {
      display in blue
    }
    or something like that.
    so how do you think i should be organizing this?
    1. each main category is its own table, with sub-links as rows
    2. everything is in 1 table and each row will have the sub-link and the main category it belongs to (but then i'd still have to have a separate table to hold all of the main categorie, right?)
    3. some other better solution.

    could you please tell me what the advantages/drawbacks of each solution are? this is the first time i'm trying to "design" a db, so i have no clue.
    thanks!
    Goals are dreams with deadlines
    -------------------------------------
    Nimlok Trade Show Displays Booths and Exhibits

  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    3) All categories in one table, each row having the category name and other properties and also the parent category id, if it's a main category, then parent is null

    Storing Hierarchical Data in a Database

  3. #3
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Answer to the "display in different colours" question:
    First of all; use css to define the style (colour etc), then you can set different class names (e.g. "active"/"inactive") for the html elements
    If you use a recursive function to print out the links, then it's very easy to send a parameter to that function to make all children (and grandchildren etc) to a certain category "inherit" the same style


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
  •