Hi, Guest ~ Login or Register

Question Regarding This Forum

Posted in Website Programming » PHP - Sunday 19th August 2007 at 9:09PM

cmellor
Member

User Avatar

Joined August 2007
Posts: 3

Hey, I have a question regarding how this forum was coded. I hope to make my own forum for an upcoming project of mine, I just want to see if I can do it :)

One thing that is puzzling me is how do you have the forums under the category in the correct order

I'm finding it hard to word this question, so bare with me, I aren't a n00b. I check the database of an IPB forum and the categories have a parent_id of -1, indicating that it's a category, then the forums underneath have a parent id of the ID of the category and will display underneath the category heading.

I can't seem to work my head around how this would be coded. I'm not sure how you did it on this forum, but if anybody has any help for me, that would be greatly appreciated.

Thanks.

- Chris.

__________________________________

 

Replies (2)

Replied - Tuesday 4th September 2007 at 1:59PM [Post Link]

Will
Administrator

User Avatar

Joined October 2005
Posts: 133

I just have one table called forum_categories, and one called forum_forums. That's the proper RDBMS way of coding, really.

__________________________________
Will Morgan
Freelance Web Developer
Next feature: How to fit 25 hours into a day!

 
Replied - Tuesday 4th September 2007 at 6:52PM [Post Link]

Tubby
Member

User Avatar

Joined July 2007
Posts: 47

On one of my sites I do it like Will, forumcategories and forums, two tables. I normally have three tables - forumthreads, forumreplies and forumcategories.

The forumcategories table has a unique ID for each, and they're added with say an ID of 1, name of General Chat, and another row is added with the ID of 2, and the name of Help. The forumthreads table has a field "category" with the category number, for example 1 if the thread was in general chat. The name in the categories is just for display, the ID is what is used to check.

Then it's simply a query of something like


$category = securityfunction($_GET['category']);
$query = @mysql_query("SELECT * FROM forumthreads WHERE category='$category'");
//echo the results etc


indeed.

__________________________________
All posts are my own opinion.