html - Create a like/dislike bar based on two numbers - PHP -


i have 2 numbers want try , create like/dislike bar from. below php , html html uses width value show amount of "like" in dislike bar. see below:

<div class="dislike_base">     <div class="like" style="width: 52%"></div> </div> 

i not sure how mathematical comparison of 2 numbers percent.

php:

$like_post_num = 13; $hate_post_num = 10; $total = $like_post_num + $hate_post_num  //how compare above information percent of 100 of likes vs dislikes. 

please let me know if not make sense?

$total = $like_post_num + $hate_post_num; $percent = round(($like_post_num / $total) * 100); 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -