Jump to content


Photo

Advise on generating sub sections categorys?


  • Please log in to reply
2 replies to this topic

#1 markcooke

markcooke
  • Members
  • Pip
  • Newbie
  • 3 posts
  • LocationGloucester, United Kingdom

Posted 22 April 2003 - 04:04 PM

Hi,

I\'m in the middle of writing a new website, and I have come across a stump,
I new to php and mysql (just thought I would pre warn),
the problem I have is I\'m uanble to work out the database structure and how to put it down in code, a parent sibling arrangement, ie.

I have a page that has a several main categories, and in them are sub categories, but in these sub categories can be the actuall story or content,

ie.

Computers (cat)
Linux (sub cat)
PHP (actuall content)
Distros (actuall content)
Windows (sub cat)
Software (actuall content)


I have figured out I would need at least 3 tables, 1 for the content, 1 for the categorys and 1 more for the sub section categorys, but I\'m not sure how to link them together,

I was thinking of putting the category and section ID\'s into a 2 fields in the content table, and putting their respective ID\'s into these fields, now this is where I come stuck!

I want to be able to show the content as listed above, but so far drawn a blank, the tables/fields I have are:

CONTENT:
ID (PRIMARY KEY)
title
story_content
date
categoryID
SectionID

CATEGORY:
ID (PRIMARY KEY)
category

SECTION:
ID (PRIMARY KEY)
section

Hopefully I have explained this ok, if not feel free to say.

Cheers

Mark

#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 22 April 2003 - 04:53 PM

i haven\'t attempted an infinite level tree yet... :? but i have a guess, setup a recursive function for:

id | parent_id | is_content | name
1 | 0 | 0 | Computers
2 | 1 | 0 | Linux
3 | 1 | 1 | PHP
4 | 2 | 1 | Distros
5 | 1 | 0 | Windows
6 | 1 | 1 | Software


there is a topic common to this involving a forum type layout, but the concept is the same. see if you can thumb through that book?

http://forums.phpfre...opic.php?t=3346
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#3 markcooke

markcooke
  • Members
  • Pip
  • Newbie
  • 3 posts
  • LocationGloucester, United Kingdom

Posted 22 April 2003 - 07:16 PM

Cheers,

Just read the other post and I\'m going to order it from amazon anyway (as my local book shop is somewhat limited) , as you cannot ever have to many books :)

Thanks for the advise, it seems very, very similar to what I\'m after.

Cheers again

Mark




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users