# PHP + MYSQL: Return ID of a row after insertion

**URL:** <https://forum.kirupa.com/t/php-mysql-return-id-of-a-row-after-insertion/244455>\
**Category:** programming\
**Created:** [November 18, 2007, 2:17pm UTC](https://forum.kirupa.com/t/php-mysql-return-id-of-a-row-after-insertion/244455 "2007-11-18T14:17:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![silverType](https://avatars.discourse-cdn.com/v4/letter/s/ac91a4/32.png) [@silverType](https://forum.kirupa.com/u/silverType)\
**Post date:** [November 18, 2007, 2:17pm UTC](https://forum.kirupa.com/t/php-mysql-return-id-of-a-row-after-insertion/244455/1 "2007-11-18T14:17:07Z")

</div>

Hi guys,

I have 2 tables, namely ‘test\_suite’ and ‘test\_case’. The test\_suite contains an testsuiteID which is the primary key of the table and will auto increment with each row inserted. After an insertion, I want to retrieve the testsuiteID of the newly inserted row, and insert it into the test\_case table. How can I achieve that? Anyway, I am not using any functions or stored procedures in mysql. All commands are executed on-the-fly via the ‘mysql\_query’ command in php. Any help would be greatly appreciated. Thanks in advance.
