I dont really know how to explain this,
I have a categorys table and it consists of 4 rows.
"id" , "categoryname" , "category_description" and "belongsto"
The first 3 are self explanatory, The forth one is for "Sub categorys"
So when you are viewing a category, it has a section where "belongsto" equals to the current categorys ID.
So yeah, You can currently have sub categorys. And if you set belongsto to a subcategorys ID, you would have a "Sub-sub category"
And you could go on forever... "sub-sub-sub-sub category"
Anyway, Thats not the problem
The problem is, I have an "Add page" and "Add category" form
For the add category form, I need a listbox that consists of all the categorys, sub categorys, sub-sub categorys etc...
So it will look something like this:
"Main category" (This will add the category in "Main Category")
"Main category -> A sub category" (This will add the category in a subcategory for Main category"
I can do that so far, But what if you have a sub-sub category?
I can do this to BUT, For each sub level, I will need to manualy put a while($row=.......){ and thats not what I need.
Hope you understand so far, Because im now asking my main question...
I need this in code please 🙂 :
SQL = SELECT * FROM categorys
foreach category SQL = SELECT * FROM categorys WHERE belongto this category
Then I need some sort of loop to check for the sub sub sub sub categorys
Ahh sod it, im lost
I cant even put this in pseudocode because I have no ****ing idea what I need to do 😢
Please someone help, Because this is really stressing me out
Edit: okay ive calmed down abit.
If you cant be bothered to read all that
I need unlimited sub category support
So you can add a sub-sub-sub-sub-sub-sub-sub-sub-sub-category if you wanted to
AND display then in a textbox
category
category->sub category
category->sub category->subsub category
category->sub category->subsub category->another category
category->sub category->subsub category->another category->blah