eerikk2 Posted February 5, 2010 Share Posted February 5, 2010 So i am looking to display the last 10 entries of my mysql database. The basics are you can upload data from my website along with a picture. I want to display the most recently uploaded pictures in the websites banner. is there a way to do this? Link to comment https://forums.phpfreaks.com/topic/191001-display-most-recent-mysql-entry/ Share on other sites More sharing options...
Hussam Posted February 5, 2010 Share Posted February 5, 2010 use this SQL statement: $query = "SELECT * FROM table_name LIMIT 10 ORDER BY id DESC" if your id field is set to "Auto Increment" then you should get the most recent 10 records. I haven't tried it that way but give it a try and tell me what happens. good luck. Link to comment https://forums.phpfreaks.com/topic/191001-display-most-recent-mysql-entry/#findComment-1007310 Share on other sites More sharing options...
eerikk2 Posted February 6, 2010 Author Share Posted February 6, 2010 well so i gave it a shot and i'm having issues with the LIMIT 10 Link to comment https://forums.phpfreaks.com/topic/191001-display-most-recent-mysql-entry/#findComment-1007779 Share on other sites More sharing options...
trq Posted February 6, 2010 Share Posted February 6, 2010 i'm having issues with the LIMIT 10[ What is the issue exactly? Link to comment https://forums.phpfreaks.com/topic/191001-display-most-recent-mysql-entry/#findComment-1007785 Share on other sites More sharing options...
eerikk2 Posted February 6, 2010 Author Share Posted February 6, 2010 strike that. the LIMIT, it just has to be put at the end of the query other wise the syntax is incorrect. Thank you very much for your help this was exactly what i was looking for Link to comment https://forums.phpfreaks.com/topic/191001-display-most-recent-mysql-entry/#findComment-1007786 Share on other sites More sharing options...
Hussam Posted February 6, 2010 Share Posted February 6, 2010 True, that was stupid mistake I did, but not on purpose lol. I am sorry, I just have not written an SQL statement in ages since I no longer write raw php, I was just trying to help I will alter my post for others who have the same question. good luck. Link to comment https://forums.phpfreaks.com/topic/191001-display-most-recent-mysql-entry/#findComment-1007798 Share on other sites More sharing options...
Hussam Posted February 6, 2010 Share Posted February 6, 2010 I am not sure why I can't edit this reply, but anyway, here is the correct syntax: $query = "SELECT * FROM table_name ORDER BY id DESC LIMIT 10"; cheers! Link to comment https://forums.phpfreaks.com/topic/191001-display-most-recent-mysql-entry/#findComment-1007799 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.