Get Last Mysql Row From Database Retrieve Last Entry ID From Table



Get Last Mysql Row From Database Retrieve Last Entry ID From Table
 (380) Click. Work. Collect
Get Last Mysql Row From Database Retrieve Last Entry ID From Table
Post Description:
Post Tags: get, last, mysql, row, from, database, retrieve, last, entry, id, from, table
This Post Has Been Viewed 1985 Times Since Wed May 30, 2007 8:27 am Posted By hostman with 0 replies
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.

Leave Your Comments     [ dejar commentarios ]
  * Name     [nombre]

  * eMail (will not be published)     [coreo electronico]

* Enter Your Reply or Comments:    [commentarios]


Add Picture To Comments         [incluir foto]
YES NO             upload
Receive Replies on my Comments (An email will be sent to you when someone replies to your comments)

     

Comments and replies About Get Last Mysql Row From Database Retrieve Last Entry ID From Table




(0) Comments