Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have a problem with sort. I have to calculate in a table how many times an
individual user appears; I also have to show 3 users who appear the most.

Can somebody please help with an example of how to do this?


Re: Sort

I'm assuming this is a MySQL question.  Here's a query that illustrates how
to count repititions in table:

SELECT COUNT( userid ) AS repetitions, userid FROM `table`
GROUP BY userid
ORDER BY repetitions DESC

This would return a list of distinct userids and the number of times each
userid appeared in the table, in descending order.

Quoted text here. Click to load it

Re: Sort

Quoted text here. Click to load it

The function you need is array_count_values(). Sort the result with asort()
for the second part of your problem.

Site Timeline