Jump to content

Archived

This topic is now archived and is closed to further replies.

markcooke

Advise on generating sub sections categorys?

Recommended Posts

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

Share this post


Link to post
Share on other sites

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.phpfreaks.com/viewtopic.php?t=3346

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.