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

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.

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. 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.