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
https://forums.phpfreaks.com/topic/113883-simple-dbtree/
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
https://forums.phpfreaks.com/topic/113883-simple-dbtree/#findComment-586262
Share on other sites

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.