today i wanted to get the last entry of a database.

for example, i had a table with user names and each user had a user_id field, this field was incrementing so each user_id was unique. so as new users signed up, a new user_id was created but i wanted a way to get the last user_id for a script i was writing so this is the way i found out on using php to search and getting the id of the last inserted row in mysql through php.

you can use this query to get the results you want with this sql query i created to use as en example:

code:
$sql = "SELECT user_id FROM my_users_table ORDER BY user_id DESC LIMIT 0,1";


this will retrieve the last entry on your database and you can use it or display it on your script.