3raser Posted March 9, 2012 Share Posted March 9, 2012 I really made a poll system that allows users to voice their opinions within the community. Although the system is nearly complete, I can't seem to get the percentages working. Each option in the poll seems to have the incorrect percentage. I've tried several fixes but can't seem to get anything to work. :/ Current code: http://pastebin.com/dr6Ab1vR Picture of problem: Quote Link to comment https://forums.phpfreaks.com/topic/258569-poll-percentages/ Share on other sites More sharing options...
q11we Posted March 9, 2012 Share Posted March 9, 2012 You might have mistaken while rounding. round(($num_of_results/$total))*100 will either give you 100% or 0%. Instead try using round((100*$num_of_results/$total)) that will give rounded percentage. Quote Link to comment https://forums.phpfreaks.com/topic/258569-poll-percentages/#findComment-1325442 Share on other sites More sharing options...
3raser Posted March 9, 2012 Author Share Posted March 9, 2012 Thank you! That was the problem. Quote Link to comment https://forums.phpfreaks.com/topic/258569-poll-percentages/#findComment-1325681 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.