Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2003
    Posts
    30

    Unanswered: How to get the latest inserted ID

    I'm developing a php web application. When I insert a user's information from a html form to a USER table, I also need to insert some data to 2nd table. There's a "contact_id" in 2nd table related with "user_id" (auto_increment) in USER table. But I just don't know how I can get the latest inserted user's ID from USER table and insert it into the 2nd table "contact_id" field.

    Please give me some hint.
    Last edited by sunnyside; 09-27-04 at 16:55. Reason: previous problem has been solved

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    use the mysql_insert_id() function
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Aug 2003
    Posts
    30
    Thank you so much. Help me a lot! :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •