PHP: Just got into mysql_insert_id() is very useful.

Long ago I have been programming with PHP but I am having problem in getting the inserted key for the new record that I have just inserted to my database.

 

My turn around was to query the same data that I have inserted. Recently, it just to  my head if there is a function on the net that perform the said task. And poof there it is. mysql_insert_id();

Usage

1. Perform an insert query. ea. INSERT INTO name(`name`) VALUES(‘NAME’)

2. Use the function to get the primary-auto-increment key. $id = mysql_insert_id();

Thats it you have get the key of your inserted record.

 

Hope it help you.

3 thoughts on “PHP: Just got into mysql_insert_id() is very useful.

  1. Pingback: Nylon Feet

  2. Pingback: http://www.forfait-sans-engagement.org

  3. Pingback: Bronzeskulpturen

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.