Jump to content

help me in deleting category and its subcategory in a tree


venky_lb

Recommended Posts

Hi,

consider the following example

id  code                      description                          parent

1    01                        car                                        0

2    011                      hyundai                                  01

3    0111                    verna                                    011

4      02                        bus                                        0

 

ig goes like this,

 

 

now if i delete car that should not be deleted because it has subcategories,but i should be able to delete categories which doesnt has subcategory i.e bus .

pls help me out in this.

 

Regards

venkat

Link to comment
Share on other sites

To clarify for him: he seems to be asking about the logic of it.

 

Personally I wouldn't do the categories like that in the database....

 

But if you don't want it to be deleted, you will have to do a check before you delete it. For example: SELECT * FROM table WHERE CODE LIKE '01%'

 

if (mysql_num_rows($query) > 1), then it should not be deleted.

Link to comment
Share on other sites

Hi,

consider the following example

id  code                      category                          parent

1    01                        car                                        0

2    011                      hyundai                                  01

3    0111                    verna                                    011

4      02                        bus                                        0

5      021                      volvo                                    02     

 

it goes like this,

can any one tell the logic how to add a new subcategory, which should automatically increment the code

i.e my html form for adding record

 

->used select button and  displayed all category in it,

->used a text boc to enter the new record

 

now,i can select anyone of category from select menu(eg car) and  entered a new record (eg ferrari).if i click submit it should be stored in db such a way that code   012

 

pls help me out in this. 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.