slain84 Posted August 4, 2006 Share Posted August 4, 2006 Hi everyone,I am going to program an ads page. Every ad belongs to a category. An example:--> Cars --> Porsche --> Cayenne--> DVDs --> Action-Movies --> >18 years --> Lethal Weapon 3Thus, there might be several sub-categories. This is no problem at all, but these sub-categories should be created by the admin later dynamically. He should be able to click through the categories and add a sub-category to "Cayenne" for example.I have now the problem that I do not really know how to set up the MySQL database and how a script should look like so that the added categories are displayed.I was thinking about adding fields to the category table in the database. That means that cat01 stands for the first sub-category, cat02 for the second and so on. If the admin adds a new, a new cat03 must be created. I do not how to implement that in my PHP script though.Can anyone help?Thanks,Dominik Quote Link to comment https://forums.phpfreaks.com/topic/16524-dynamic-creation-of-categories-mysqlphp/ Share on other sites More sharing options...
manmadareddy Posted August 4, 2006 Share Posted August 4, 2006 you just need to have CategoryID,CategoryName,ParentID,Level,statusI hope these fields are sufficient. Quote Link to comment https://forums.phpfreaks.com/topic/16524-dynamic-creation-of-categories-mysqlphp/#findComment-69054 Share on other sites More sharing options...
gerkintrigg Posted August 4, 2006 Share Posted August 4, 2006 yeah, provoded that you have parentID (as suggested above) you can state what level the category is at. If the parent id field is empty, your system can assume it's a top-level category and you can go from there.Thanks for the suggestion... I think I'll do it that way too... ;o) Quote Link to comment https://forums.phpfreaks.com/topic/16524-dynamic-creation-of-categories-mysqlphp/#findComment-69133 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.