dezkit Posted May 4, 2008 Share Posted May 4, 2008 how do i select the 5 latest mysql fields, i got ID int example code: <?php // Make a MySQL Connection $query = "SELECT * FROM example"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo $row['name']. " - ". $row['age']; echo "<br />"; } ?> Quote Link to comment Share on other sites More sharing options...
Bauer418 Posted May 4, 2008 Share Posted May 4, 2008 Well assuming your ID field is an auto_increment, you should just be able to run this query: SELECT * FROM example ORDER BY id DESC LIMIT 5 Which will grab the 5 most recent items in the database, assuming that is what you want. Quote Link to comment Share on other sites More sharing options...
dezkit Posted May 4, 2008 Author Share Posted May 4, 2008 thanks, +bookmarked Quote Link to comment 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.