faqts : Computers : Programming : Languages : PHP : Database Backed Sites : General

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

118 of 141 people (84%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How do I read the last record and only the last record from a table?

Dec 13th, 2000 19:50
Marc DePoe, Jason Parrett, agnes rynkiewicz, Ben Udall,


This should work if you have an auto increment id for each record.
$sql=myql_query("SELECT * FROM table ORDER BY id DESC LIMIT 1");
if you have an id field... try this ...
$sql=myql_query("SELECT MAX(id) from table");