Jump to content

simple dbtree


venky_lb

Recommended Posts

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  or any link similar to this scenario 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

Hi,

 

What database system are you using? I presume it's MySQL. If so, why are you using ids like 01 and 011. Why not use integer ids like 1, 2, 3, 4 which are sequential. If you use sequential ids, you can tell MySQL to auto increment the ids for you. So say the last entry has id of 11, when you insert a new one MySQL will automatically give the new row an id of 12.

 

Robin

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.