adamjones Posted October 31, 2008 Share Posted October 31, 2008 Hi. So, I have this code; <?php $DB_Query = @mysql_query("SELECT * FROM `news` WHERE 1 ORDER BY `ID` DESC") OR die('MySQL error: '.mysql_error()); ?> But I want it to only echo the last 2 entries. How can I achieve this? Adam. Link to comment https://forums.phpfreaks.com/topic/130808-solved-how-to-echo-only-the-last-two-entries/ Share on other sites More sharing options...
bobbinsbro Posted October 31, 2008 Share Posted October 31, 2008 last 2 by date, or last 2 by id? Link to comment https://forums.phpfreaks.com/topic/130808-solved-how-to-echo-only-the-last-two-entries/#findComment-678923 Share on other sites More sharing options...
adamjones Posted October 31, 2008 Author Share Posted October 31, 2008 Date Link to comment https://forums.phpfreaks.com/topic/130808-solved-how-to-echo-only-the-last-two-entries/#findComment-678924 Share on other sites More sharing options...
adamjones Posted October 31, 2008 Author Share Posted October 31, 2008 ..anyone? Link to comment https://forums.phpfreaks.com/topic/130808-solved-how-to-echo-only-the-last-two-entries/#findComment-678937 Share on other sites More sharing options...
revraz Posted October 31, 2008 Share Posted October 31, 2008 You want to order by date and do a limit 2 Link to comment https://forums.phpfreaks.com/topic/130808-solved-how-to-echo-only-the-last-two-entries/#findComment-678939 Share on other sites More sharing options...
adamjones Posted October 31, 2008 Author Share Posted October 31, 2008 How do I do that? Link to comment https://forums.phpfreaks.com/topic/130808-solved-how-to-echo-only-the-last-two-entries/#findComment-678941 Share on other sites More sharing options...
bobbinsbro Posted October 31, 2008 Share Posted October 31, 2008 "SELECT * FROM `news` ORDER BY date DESC LIMIT 2" i think Link to comment https://forums.phpfreaks.com/topic/130808-solved-how-to-echo-only-the-last-two-entries/#findComment-678945 Share on other sites More sharing options...
adamjones Posted October 31, 2008 Author Share Posted October 31, 2008 thanks, all working Link to comment https://forums.phpfreaks.com/topic/130808-solved-how-to-echo-only-the-last-two-entries/#findComment-678950 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.