Jump to content

Recommended Posts

Hiya,
I just wondered if anyone could suggest a way of ordering Mysql output based on how many votes of a certain type there were for a certain member.

I have two tables: member and votes. I want to select the three members with the most number of positive votes and the three members with the most amount of negative votes and display them in a table.

Once I have the data in an array, I can work out the formatting myself, but it's not easy getting the array in the first place.

Ideally I'd like to take each member in turn, work out how many people voted yes, how many people voted no and work out their average "yes" vote out as a percentage. Then use this percentage as a way of ordering the results and outputting the highest 3 and the lowest 3 (preferably in two seperate queries so that I can use them differently).

I just really don't know where to start.

Can anyone point me in the right direction please?

Regards,
Neil
Link to comment
https://forums.phpfreaks.com/topic/30868-ordering-by-counting-mysql-rows/
Share on other sites

Table names:

member
Which contains:
fname,  sname,  username,  password,  sex,  orientation,  age,  email,  area,  description,  subscriber,  status,  reg_date,  last_checked,  online,  id

And: 
pokes
Which contains:
poker,  poked,  pop,  expire,  poke_deleted,  ip,  id

I need to know how to get the average pop for a user (pop is an enum that can either be "pig" or "poke") so I need to count all pigs and all pokes for each member, then order the members table depending on the percentage pokes of the total pig and poke vote for that member and output only the top three and only the bottom three...

I hope this makes sense.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.