How to get the last inserted ID of a MySQL table in PHP?

Spread the love

Sometimes, we want to get the last inserted ID of a MySQL table in PHP.

In this article, we’ll look at how to get the last inserted ID of a MySQL table in PHP.

How to get the last inserted ID of a MySQL table in PHP?

To get the last inserted ID of a MySQL table in PHP, we can use various properties.

If we’re using PDO, we use PDO::lastInsertId.

If we’re using Mysqli, we use mysqli::$insert_id.

Conclusion

To get the last inserted ID of a MySQL table in PHP, we can use various properties.

Leave a Reply

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