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>'; } Quote 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 Quote 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? Quote 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/ Quote 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.. Quote Link to comment https://forums.phpfreaks.com/topic/188484-fetch-last-4-rows/#findComment-995078 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.