Page 1 of 1

increment drop down list category id

Posted: Mon Mar 30, 2009 2:09 am
by greedyisg00d
I have a drop list which the values are retrieve from the database

id name
1 meeting
2 conference
3 workshop

I also included a textbox field where user can add drop down values. My question is for example when the user adds a value "seminar" in the database, its id must be 4 which goes like this.

4 seminar

Any idea on how it will be? Sample code is much appreciated.

Thanks

Re: increment drop down list category id

Posted: Mon Mar 30, 2009 4:29 am
by mattpointblank
Just set the ID column in your database to auto increment and primary key, and it will do this automatically when you add a new row.

Re: increment drop down list category id

Posted: Mon Mar 30, 2009 4:32 am
by php_east
adding to what matt said, add an id 0. the autoincrement will set it to the highest value automatically.