Solar Posted May 25, 2011 Share Posted May 25, 2011 Lets say I have a simple table for Categories; fidforumdesccat 1General Forumdesc here1 2Help Forumdesc here2 3Console Forumdesc here3 Hello! I think I need some creative juice to start my flow and am thankful for any suggestions. I am looking into some advice on how to code in "Category" wise. Lets say if I have forums like this; General Forum General Talk about anything in general to NewbWorld. Suggestions Have any ideas to give to NewbWorld? Anything Goes Talk about anything you want! Help Forum HTML Help If you are having problems with HTML coding post here! PHP Help If you are having problems with PHP coding post here! Instead of me manually coding each Category (General Forum, Help Forum, Console Forum, etc)... I want to be able to have the following coded like so; List Category ---Forum Sub Category ---Forum Sub Category ---Forum Sub Category List Category 2 ---Forum Sub Category ---Forum Sub Category ---Forum Sub Category Right now; I've been coding the "List Category" manually to show "Sub Forums". I would like to know how to do this without manual anymore. I would love to start coding an admin/moderator panel soon. Any help is much appreciated and thankyou for your time! Quote Link to comment https://forums.phpfreaks.com/topic/237379-forum-hint/ Share on other sites More sharing options...
xyph Posted May 25, 2011 Share Posted May 25, 2011 You can add a parent column. If there's no parent, it's a main category, otherwise put it with a parent category. This can be recursive, for sub-sub-categories as well. Quote Link to comment https://forums.phpfreaks.com/topic/237379-forum-hint/#findComment-1219807 Share on other sites More sharing options...
Solar Posted May 25, 2011 Author Share Posted May 25, 2011 Oooh, Sorry about that. yes. The "Cat" column my first post is the main Categories. My Sub Forums database has a cat column as well. So the forums showed in the main Category. But you answering: I believe I have the idea. Keep Main Categories and Sub Categories all in the same database? Is that a good idea to do? I think that is an easy route to take. If not; any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/237379-forum-hint/#findComment-1219817 Share on other sites More sharing options...
xyph Posted May 25, 2011 Share Posted May 25, 2011 That's up to you. If you want a tree that goes deeper than 2 levels, you probably want a single table. Also, if both parent and subcategories are going to reference similar data, it will be easier to use a single table. For example, if your parent categories will contain forum posts and you have two different tables, you will have a VERY hard time referencing posts to a category, because some parent and sub categories will have the same IDs Does this make sense? The advantage of using one table is you KNOW that each category, sub or parent, will have it's own unique ID Quote Link to comment https://forums.phpfreaks.com/topic/237379-forum-hint/#findComment-1219822 Share on other sites More sharing options...
Solar Posted May 25, 2011 Author Share Posted May 25, 2011 This makes perfect sense; I never thought of it that way! Thank you very much for your time. Threads and post will go in a different database with their own unique ID as well! Quote Link to comment https://forums.phpfreaks.com/topic/237379-forum-hint/#findComment-1219832 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.