Hello guys,
I've been working on a project recently and now my client wants a YouTube like/dislike bar
Anyway, I have been tampering with this like/dislike formula for a few hours now and it is starting to make me frustrated. This is what I have so far:
Code:
$likes and $dislikes sql query~
$a = $likes;
$b = $dislikes;
$c = $a/$b*100;
<div style="width:<?php echo $c; ?>%;"></div>
I am trying to echo out a percentage to display the dislike/like ratio using a divs width.
Unfortunately this code is not scalable and bugs under certain conditions i.e. if $b=>$a or $a==$b.
Does anyone have a solid formula I could learn from?