chrziz Posted April 13, 2006 Share Posted April 13, 2006 I am trying to figure out the best way create a categories system that can have unlimited sub categories with PHP and MySQL.I tried a few different methods but I cannot get any to work properly.So far what I have is a table with the following structure:categories -cat_ID -cat_name -parent_cat_ID I am trying to figure out how to create a loop that when given a cat_ID it keeps on grabbing the parent_cat_ID and cat_name until it gets to the top.Is this the best way of doing this or is there a simpler way? Quote Link to comment Share on other sites More sharing options...
craygo Posted April 13, 2006 Share Posted April 13, 2006 2 tables would be the best way to do what you needcat_table:cat_idcat_descriptionblah blahblahsub_cat_tablesub_idcat_idsub_descriptionblahblahblahNow put all your main catagories in one table and when you enter in the info for the sub catagories you just enter in the cat_id for the main catagory.And when you run quries you just join by cat_id.Ray Quote Link to comment Share on other sites More sharing options...
chrziz Posted April 13, 2006 Author Share Posted April 13, 2006 Ok, thanks a lot! Quote Link to comment 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.