markcooke Posted April 22, 2003 Share Posted April 22, 2003 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 Quote Link to comment https://forums.phpfreaks.com/topic/382-advise-on-generating-sub-sections-categorys/ Share on other sites More sharing options...
effigy Posted April 22, 2003 Share Posted April 22, 2003 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 Quote Link to comment https://forums.phpfreaks.com/topic/382-advise-on-generating-sub-sections-categorys/#findComment-1295 Share on other sites More sharing options...
markcooke Posted April 22, 2003 Author Share Posted April 22, 2003 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 Quote Link to comment https://forums.phpfreaks.com/topic/382-advise-on-generating-sub-sections-categorys/#findComment-1296 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.