There is a function to know what was the last id inserted in the current connect

Im MySQL

SELECT LAST_INSERT_ID();

With PDO:

$pdo->lastInsertId();

With Mysqli:

$mysqli->insert_id;

Leave a Reply

Your email address will not be published. Required fields are marked *