NeoMarine Posted June 11, 2009 Share Posted June 11, 2009 I hold two statistics in my database, one for "Thumbs Up" and one for "Thumbs Down". Based on the ratio of Thumbs up/down, I want to display a message to the user such as: "You are generous" (mostly thumbs up) or "You are ungenerous" (mostly thumbs down). I have the following math done: $thumbsCombinedTotal=$thumbsUpCount+$thumbsDownCount; $thumbsUpPercentage=round(($thumbsUpCount/$thumbsCombinedTotal)*100,2); However, if the user has thumbs up = 1, and thumbs down = 0 - this will generate a value of 100% so I would say "you are extremely generous". But what I really would like to say is, "you are generous", because they have only voted on 1 thing altogether. Can you think of some more detailed math so I can determine a more accurate description of their "favor in the ratio" (ie. how generous they are actually being?) I need some kind of gradual scale in the math, which means, the more COMBINED thumbsup+thumbsdown they have, the more it will influence the severity of their generousity/ungenerousity. I hope I am clear enough. Thanks a lot to whoever can help me. Quote Link to comment Share on other sites More sharing options...
cloudy243 Posted June 18, 2009 Share Posted June 18, 2009 I would do something more like if ($thumbsUpCount > thumbsDownCount) { echo "You are generous."; } else { echo "You are ungenerous."; } or for something even better $generosity = $thumbsUpCount - $thumbsDownCount; if ($generosity < -50) { echo "You are very ungenerous."; } elseif ($generosity < 0) { echo "You are ungenerous."; } elseif ($generosity < 20) { echo "You are generous."; } elseif ($generosity > 21) { echo "You are very generous."; } Quote Link to comment 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.