- Forums
- PHP
- Get Last Mysql Row From Database Retrieve Last Entry ID From Table
This Page Contains information about Get Last Mysql Row From Database Retrieve Last Entry ID From Table By wallpaperama in category PHP with 31 Replies. [1034], Last Updated: Sat May 18, 2024
wallpaperama
Wed May 30, 2007
31 Comments
17207 Visits
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.
My table has only 'name' column
& I want to find out last inserted record...