eugene2009 Posted January 14, 2010 Share Posted January 14, 2010 how would i do it for mysql where it would only fetch the last 4 most RECENT rows? ? i dont want all.. i just always want the last 4.. while($row = mysql_fetch_array($result)) { echo $row['name']; echo '<br>'; } Link to comment https://forums.phpfreaks.com/topic/188484-fetch-last-4-rows/ Share on other sites More sharing options...
Zane Posted January 14, 2010 Share Posted January 14, 2010 SELECT * FROM table ORDER BY id DESC LIMIT 4 Link to comment https://forums.phpfreaks.com/topic/188484-fetch-last-4-rows/#findComment-995052 Share on other sites More sharing options...
eugene2009 Posted January 14, 2010 Author Share Posted January 14, 2010 thanks.. and whats the correct way to fetch 4 random ones? Link to comment https://forums.phpfreaks.com/topic/188484-fetch-last-4-rows/#findComment-995055 Share on other sites More sharing options...
Zane Posted January 14, 2010 Share Posted January 14, 2010 Here's a nice tutorial http://jan.kneschke.de/projects/mysql/order-by-rand/ Link to comment https://forums.phpfreaks.com/topic/188484-fetch-last-4-rows/#findComment-995076 Share on other sites More sharing options...
eugene2009 Posted January 14, 2010 Author Share Posted January 14, 2010 Spasiba.. Link to comment https://forums.phpfreaks.com/topic/188484-fetch-last-4-rows/#findComment-995078 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.