increment drop down list category id

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
greedyisg00d
Forum Commoner
Posts: 42
Joined: Thu Feb 12, 2009 2:48 am

increment drop down list category id

Post 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
mattpointblank
Forum Contributor
Posts: 304
Joined: Tue Dec 23, 2008 6:29 am

Re: increment drop down list category id

Post 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.
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: increment drop down list category id

Post by php_east »

adding to what matt said, add an id 0. the autoincrement will set it to the highest value automatically.
Post Reply