gerkintrigg Posted December 16, 2006 Share Posted December 16, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/30868-ordering-by-counting-mysql-rows/ Share on other sites More sharing options...
HuggieBear Posted December 16, 2006 Share Posted December 16, 2006 Try this...Can you provide the table names and column names in your database?RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/30868-ordering-by-counting-mysql-rows/#findComment-142388 Share on other sites More sharing options...
gerkintrigg Posted December 16, 2006 Author Share Posted December 16, 2006 Table names: memberWhich contains:fname, sname, username, password, sex, orientation, age, email, area, description, subscriber, status, reg_date, last_checked, online, idAnd: pokesWhich 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. Quote Link to comment https://forums.phpfreaks.com/topic/30868-ordering-by-counting-mysql-rows/#findComment-142424 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.