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 />"; } ?> Link to comment https://forums.phpfreaks.com/topic/104107-solved-php-mysql-select/ 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. Link to comment https://forums.phpfreaks.com/topic/104107-solved-php-mysql-select/#findComment-532992 Share on other sites More sharing options...
dezkit Posted May 4, 2008 Author Share Posted May 4, 2008 thanks, +bookmarked Link to comment https://forums.phpfreaks.com/topic/104107-solved-php-mysql-select/#findComment-532997 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.