dongre6404
2010-07-11 19:59
浏览 15
已采纳

禁用文本框显示值

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 user 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?

图片转代码服务由CSDN问答提供 功能建议

我有一个书形式,其中有一个ID字段。 我希望[disabled]文本框在用户尝试填写表单时显示mysql的ID。

它应该检查数据库中的最后一个id,并相应地显示下一个id。 例如,如果输入的最后一个id是8,那么它应该显示给新用户9.如何预生成文本框以显示id?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongzun9958 2010-07-11 20:27
    已采纳

    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.

    已采纳该答案
    打赏 评论
  • douju6542 2010-07-11 20:38

    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

    打赏 评论

相关推荐 更多相似问题