Welcome Guest, Not a member yet? Register   Sign In
Sort results by number of using
#3

[eluser]aquary[/eluser]
You'll need a query to count number of news in each category, then sort it by the count... though this might be slow when your table got bigger...

Code:
// convert it to CI's AR yourself.
SELECT categories.*, COUNT(categories.ID_category) AS usage_time FROM categories JOIN news ON news.ID_category=categories.ID_category ORDER BY count(categories.ID_category) limit 5;

Not tested but something along that line. However, this is only limited to categories with at least 1 news inside. Empty categories will not be shown.


Messages In This Thread
Sort results by number of using - by El Forum - 03-09-2012, 11:31 AM
Sort results by number of using - by El Forum - 03-09-2012, 03:20 PM
Sort results by number of using - by El Forum - 03-09-2012, 11:07 PM
Sort results by number of using - by El Forum - 03-14-2012, 10:22 AM
Sort results by number of using - by El Forum - 03-23-2012, 06:46 AM



Theme © iAndrew 2016 - Forum software by © MyBB