disabled textbox displaying value
i have a book form in which there is an ID field. i'd like the [disabled] textbox to display the ID from mysql when the us开发者_运维问答er tries to fill the form.
it should check the database for the last id and accordingly display the next id. for example, if the last id entered is 8, then it should display to the new user- 9. how would i pre-generate the textbox to show the id?
Make the id column in MySQL AUTO_INCREMENT
so the id is increment automatically on every insert. Then get the inserted id through PDO::lastInsertId
or mysql_insert_id
. No need to display to the user.
You don't need to display this information to the user. Use an auto_increment
primary key field and once the user submits the form, insert a NULL
value for that field in your insert statement. When an auto_increment
field is passed a NULL
value, it will insert the next value in the sequence.
http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html
精彩评论