0

I have master categories table like this

category_id    category_name            parent_name           parent_id
     1         animals & pet supplies       null                   0
     2         live animals            animals & pet supplies      1
     3         pet supplies            animals & pet supplies      1
     4         bird supplies           pet supplies                3
     5         clothing                     null                   0
     6         mens clothing           clothing                    5
     7         womens clothing         clothing                    5
     8         shirts                  mens clothing               6
     9         formal shirts           shirts                      8 

when the user selects category i need to create new table with all categories and subcategories & sub sub categories (infinity subcategories). for example if user selects animals & pets supplies the new category table should be like this

  category_id    category_name            parent_name           parent_id
     1         animals & pet supplies       null                   0
     2         live animals            animals & pet supplies      1
     3         pet supplies            animals & pet supplies      1
     4         bird supplies           pet supplies                3

if the user selects clothing category then new category table should be like this

 category_id    category_name            parent_name           parent_id
     5         clothing                     null                   0
     6         mens clothing           clothing                    5
     7         womens clothing         clothing                    5
     8         shirts                  mens clothing               6
     9         formal shirts           shirts                      8 

anybody please help me in achieving this. thanks in advance. suggestions to change in table designing also welcome to achieve this

1 Answer 1

0

Why do you need to create new table on selection?

Can user select any sub category directly ? i.e. Instead of clothing, Men's Clothing

Regards, Maulin.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.