samona Posted June 13, 2008 Share Posted June 13, 2008 Is there a way using PHP that I can retrieve the last record with a certain field value from a MySQL server? Link to comment https://forums.phpfreaks.com/topic/110075-solved-get-last-entry-from-database/ Share on other sites More sharing options...
craygo Posted June 13, 2008 Share Posted June 13, 2008 You can use mysql_insert_id() this will retrieve the last id(in the auto_increment field) that was inserted http://us3.php.net/manual/en/function.mysql-insert-id.php Ray Link to comment https://forums.phpfreaks.com/topic/110075-solved-get-last-entry-from-database/#findComment-564835 Share on other sites More sharing options...
rhodesa Posted June 13, 2008 Share Posted June 13, 2008 also, if you have an auto_incremented unique ID in the DB, you can sort that descending: SELECT * FROM tablename WHERE somefield = 'abc' ORDER BY idfield DESC LIMIT 1 Link to comment https://forums.phpfreaks.com/topic/110075-solved-get-last-entry-from-database/#findComment-564839 Share on other sites More sharing options...
samona Posted June 13, 2008 Author Share Posted June 13, 2008 Thanks Guys!! Link to comment https://forums.phpfreaks.com/topic/110075-solved-get-last-entry-from-database/#findComment-564896 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.