PDA

View Full Version : auto_increment question


n8w
7-11-05, 08:19 PM
I have a table with the primary key id field to auto_increment
.. after I submit a record I would like it to pass this id number back to the browser so I can proceed to do other things based on the primary key

for example I have a news item .. the news_id auto increments it as the primary key and then I would like to get this number so i can than proceed to upload an image and rename it with this number

thanks a ton!!!!!!!!!

RTH10260
7-12-05, 12:08 AM
I have a table with the primary key id field to auto_increment
.. after I submit a record I would like it to pass this id number back to the browser so I can proceed to do other things based on the primary key

for example I have a news item .. the news_id auto increments it as the primary key and then I would like to get this number so i can than proceed to upload an image and rename it with this number

thanks a ton!!!!!!!!!Use the php function mysql_insert_id() to retrieve it after the mysql_query('insert ... whatever ...').
Ref: http://us3.php.net/manual/en/function.mysql-insert-id.php