Question and answer is powered by AnsPress.io
I want to select the last row from MySQL table while some data is inserting into the database. How can I get the last inserted ID in PHP
To select the last row of a table in PHP, follow this example code.
<?php $maxid = "SELECT MAX(id) AS user_id FROM table name"; $maxid_exe = mysqli_query($conn, $maxid); $row_id = mysqli_fetch_assoc($maxid_exe); $id = $row_id['user_id']; echo $id . "<br>"; ?>