Skip to content

Instantly share code, notes, and snippets.

@vhdm
Created September 6, 2015 21:32
Show Gist options
  • Save vhdm/7425ec813ee9723ae736 to your computer and use it in GitHub Desktop.
Save vhdm/7425ec813ee9723ae736 to your computer and use it in GitHub Desktop.
Get last inserted id
<?php
// Insert into database
mysql_query("INSERT INTO my_table (`column1`, `column2`) VALUES ('one', 'two')");
// Next Get what the auto incremented number was that was inserted
$id = mysql_insert_id();
// Display it...
echo $id;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment