NerdConcepts Posted May 24, 2007 Share Posted May 24, 2007 I've been trying to do this for a while now, and it's to the point I have to figure this out. I have a comm_rating (comment rating). values are 3=positive, 2=neutral, 1=negative. I don't want to put neutral comments since to me those don't show dissatisfaction. I am trying to take all comm_rating with 3 or 1 and fully calculate the percentage of positive feedback. Kind of like how eBay does it. I just can't figure this out. What i have found out... commCount3 and commCount1 are querys to figure out total of 3 or 1 ratings on a certain person. $totalPoints = $commCount3 - $commCount1; $allPoints = $commCount3 + $commCount1; $percent = ($totalPoints) / $allPoints * 100; if 3=26 and 1=6 I get a percentage of 58.6206896552 for some reason this doesn't seem like it is right. I'm not sure if I doing my math wrong or what. Also I just want the 58 not all the .620... Link to comment https://forums.phpfreaks.com/topic/52854-solved-finding-a-percentage/ Share on other sites More sharing options...
EKINdesigns Posted May 24, 2007 Share Posted May 24, 2007 Give this a go. $allPoints = $commCount3 + $commCount1; $percent = round(($commCount3) / $allPoints * 100); Link to comment https://forums.phpfreaks.com/topic/52854-solved-finding-a-percentage/#findComment-260971 Share on other sites More sharing options...
Barand Posted May 24, 2007 Share Posted May 24, 2007 You need to include the neutral count in the total to get the true %age of positive responses [pre] $count3 $pos_pcent = --------------------------- * 100 $count3 + $count2 + $count1 [/pre] Link to comment https://forums.phpfreaks.com/topic/52854-solved-finding-a-percentage/#findComment-261025 Share on other sites More sharing options...
penguin0 Posted May 24, 2007 Share Posted May 24, 2007 you can make neutral = 0? Link to comment https://forums.phpfreaks.com/topic/52854-solved-finding-a-percentage/#findComment-261028 Share on other sites More sharing options...
Barand Posted May 24, 2007 Share Posted May 24, 2007 Makes no difference if neutral=0 or neutral=1000. If you're counting them you get just as many. Link to comment https://forums.phpfreaks.com/topic/52854-solved-finding-a-percentage/#findComment-261037 Share on other sites More sharing options...
NerdConcepts Posted May 24, 2007 Author Share Posted May 24, 2007 Thing is, I'm not trying to even count the neutrals. A neutral is neither good or bad. Thus, EKINdesigns posted something that works perfectly and does return the right percentage. if count3 and count1 = 29 count3 = 23 count1 = 6 rounded percentage is 79% which is right. Thank a bunch. Link to comment https://forums.phpfreaks.com/topic/52854-solved-finding-a-percentage/#findComment-261150 Share on other sites More sharing options...
Barand Posted May 24, 2007 Share Posted May 24, 2007 So 100 people vote 1 person votes for a 3 98 vote a 2 1 person votes a 1 By your calculation that's 50% voted positive. I don't think so. Ever thought of a career in election rigging? Link to comment https://forums.phpfreaks.com/topic/52854-solved-finding-a-percentage/#findComment-261158 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.