smti Posted February 24, 2008 Share Posted February 24, 2008 Hello, I'm a bit stumped and need some assistance. Here is my problem: I want to show the "top 3" records in a database in descending order by id. I know how to sort the records, but how do I only display 3 of the records after they have been sorted by descending order (instead of displaying all records in desc.)? Do I need to manipulate the mysql fetch array on my PHP page? Thanks, -smti Quote Link to comment https://forums.phpfreaks.com/topic/92665-a-small-problem/ Share on other sites More sharing options...
pocobueno1388 Posted February 24, 2008 Share Posted February 24, 2008 You just need to add "LIMIT 3" to the end of your query. Here is an example: SELECT * FROM table ORDER BY DESC LIMIT 3 Quote Link to comment https://forums.phpfreaks.com/topic/92665-a-small-problem/#findComment-474876 Share on other sites More sharing options...
fenway Posted February 24, 2008 Share Posted February 24, 2008 Preferably with a ID DESC... ;-) Quote Link to comment https://forums.phpfreaks.com/topic/92665-a-small-problem/#findComment-474904 Share on other sites More sharing options...
smti Posted February 24, 2008 Author Share Posted February 24, 2008 Works like a charm. Thanks for your help! -smti Quote Link to comment https://forums.phpfreaks.com/topic/92665-a-small-problem/#findComment-474905 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.