This question already has an answer here:
I have created a php program where user can can vote on polls and after that, the poll result will displayed with only percentage, however I am facing an error in my program.
Code which I am using for percentage calculation is <?php echo round(($num_votes / $total_votes) * 100) ?>
Now If we talk about a sample poll result, assume we have five options option A - 4 votes
option B - 2 votes
option C - 4 votes
option D - 1 votes
option E - 0 votes
Total votes = 11
In this scenario the percentage result generating is option A - 36%
option B - 18%
option C - 36%
option D - 9%
option E - 0%
But the total of percentage is 99%
instead of 100%
. What I want is total should always be 100%
Any help would be appreciated
Thanks.
</div>