1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Finding out auto increment number

Discussion in 'HTML, Graphics & Programming' started by naudiz, 10 Mar 2010.

  1. naudiz

    Hitman

    Joined: 24 Apr 2007

    Posts: 545

    Location: Rochford

    Hey all. I'm using PHP and MySQL. I'm running an insert statement into a database, where the id is an auto increment number. Is there a way of finding out what this number is? I was going to use a select statement to find the latest entry into the table, but I'm not sure if this will work, as there will possibly be more than one person adding information at one time.

    Any help will be greatly appreciated
     
  2. Immsy

    Wise Guy

    Joined: 18 Oct 2002

    Posts: 2,367

    mysql_insert_id returns the ID of the last insert.
     
  3. naudiz

    Hitman

    Joined: 24 Apr 2007

    Posts: 545

    Location: Rochford

    That's brilliant thanks mate, just what I was after
     
  4. Immsy

    Wise Guy

    Joined: 18 Oct 2002

    Posts: 2,367

    No problem :)