Jump to content

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

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.