venky_lb Posted July 9, 2008 Share Posted July 9, 2008 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. Quote Link to comment Share on other sites More sharing options...
venky_lb Posted July 10, 2008 Author Share Posted July 10, 2008 can anyone help me in this issue Quote Link to comment Share on other sites More sharing options...
rmbarnes82 Posted July 10, 2008 Share Posted July 10, 2008 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 Quote Link to comment Share on other sites More sharing options...
venky_lb Posted July 11, 2008 Author Share Posted July 11, 2008 my db is mysql, and what exactly i wanna do is that, ->here id is auto incremented ->i want the code to be incremented (code is related to the names ie for car the code is 01) thanks for ur help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.