Page 1 of 1

New forum parent id system

Posted: Sat Nov 29, 2003 11:23 pm
by bobbonew
In my travels of learning php and owning my own site, I wanted to complement it with its own custom made forum. It took a while for me to think upon this forum parent id system, and I wanted some input tips on how to work it.

My concept is to have each forum take advantage of a parent_id in their mysql database. Thus, I could implement sub-forums without going the extra mile.

Majorly, I have two sections on my forum, television and movies. Their parent_id would be NULL because they are the highest you can go. If a forum has a parent_id, then it must be connected with another forum.

This is theoretically a pretty good system imo, but i'm not too sure how to work a couple things. I want to create a "bread crumb" type of navigation on each page in the forum, but how the heck would I do that? I'm thinking I should do a for each or while until the parent_id in the sql returns null, but it would compile somthing like this:

Forum Index :: Television :: Drama :: Boston Public :: Fan Discussion

Obviously Fan Discussion would be a subforum of Boston Public, but really I could have a subforum for that and another for that, so how would I create such a breadcrumb?

My other problem is that for each forum that has sub-forums inside of it, it would create a table giving links to those sub-forums. An example would be Boston Public and its sub-forum Fan Discussion. When I go to view the forum Boston Public, at the top of the page would be a table and contained in it would be a link to Fan Discussion. How would I accomplish this?..........Nvm problem solved, I would just do a select where it finds all the forums with the parent id of the current forum. Damn thats pretty easy.

And oh yeah comment on this type of forum id arrangement. Thx

Posted: Sun Nov 30, 2003 6:30 pm
by McGruff
After a quick read, I think maybe this all boils down to a good relational database design - this link might be helpful http://www.oreilly.de/catalog/javadtabp ... r/ch02.pdf

Once you've got everything linked up with foreign keys, creating nav links is just a matter of grabbing what you need from each table in a JOIN query, and wrapping that up in a hyperlink which defines the query string for the appropriate page type.