Get Last Mysql Row From Database Retrieve Last Entry ID From Table
get last mysql row from database retrieve last entry id from table
get, last, mysql, row, from, database, retrieve, last, entry, id, from, table
Get Last Mysql Row From Database Retrieve Last Entry ID From Table
Post Description: get last mysql row from database retrieve last entry id from table
POST# 406
Posted On: Fri Feb 29, 2008 12:01 pm
web hosting
Topic: Get Last Mysql Row From Database Retrieve Last Entry ID From Table
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.


No Repies
(0) Comments for Get Last Mysql Row From Database Retrieve Last Entry ID From Table

What do you think?

* name:  

* email:  

* Please enter comments:


Receive Replies on my Comments
(An email will be sent to you when someone replies to your comments)

Add image to comments
yes no             upload