Andy-H Posted December 22, 2008 Share Posted December 22, 2008 basically I want to retrieve 10 keywords from my database based on which ones occur most. The db layout is: --keyWords-- id (int)11 auto_inc primary_key wordUsed (text). timesUsed (int)11 ------ I think it has something to do with the max function but am not sure how to use it in the `Where` clause Any help appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/137966-solved-how-can-i-retrieve-data-from-a-table-based-on-the-highest-number-in-a-field/ Share on other sites More sharing options...
fenway Posted December 22, 2008 Share Posted December 22, 2008 Don't mark it "solved" unless you've posted the solution for the beneift of others. Quote Link to comment https://forums.phpfreaks.com/topic/137966-solved-how-can-i-retrieve-data-from-a-table-based-on-the-highest-number-in-a-field/#findComment-721588 Share on other sites More sharing options...
Andy-H Posted December 22, 2008 Author Share Posted December 22, 2008 $query = "SELECT wordUsed FROM keyWords ORDER BY timesUsed DESC LIMIT 10"; $result = mysql_query($query); while ($row = mysql_fetch_row($result)){ code; } Quote Link to comment https://forums.phpfreaks.com/topic/137966-solved-how-can-i-retrieve-data-from-a-table-based-on-the-highest-number-in-a-field/#findComment-721766 Share on other sites More sharing options...
fenway Posted December 23, 2008 Share Posted December 23, 2008 Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/137966-solved-how-can-i-retrieve-data-from-a-table-based-on-the-highest-number-in-a-field/#findComment-722520 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.