View Full Version : Resolved how to get percent out of 100%

sitNsmile

01-30-2010, 09:31 AM

$abcd = round($rate_yes / $rate_no * 100);

rating for both fields are +1(s)

anyone know how to tell this to tell me the percent out of a 100%

Right now this shows me % like 157%..etc I want it to be out of a 100%

so for

rate_yes = 10

rate_no = 7

Thats the votes that are logged in the DB.

the real % comes out to 157%, but how do I get it to come out to a percent by 100% so it cant go over

Thanks

Dormilich

01-30-2010, 09:46 AM

a little math would be helpful … ask yourself, what exactly is represented by 100%? is it $rate_yes, $rate_no or something else.

sitNsmile

01-30-2010, 09:51 AM

a little math would be helpful … ask yourself, what exactly is represented by 100%? is it $rate_yes, $rate_no or something else.

What im trying to do is.. blank% of people like this game.. which rate_yes ?

Dormilich

01-30-2010, 09:56 AM

yea, I understand that, but your formula ain’t right.

sitNsmile

01-30-2010, 09:59 AM

yea, I understand that, but your formula ain’t right.

Okay, any help on leading me to correcting that? Out of 17 votes, 10 people liked it, just need it to read the percent of that out of a 100% ?

Dormilich

01-30-2010, 10:01 AM

so you need to translate 10 / 17 into PHP code …

sitNsmile

01-30-2010, 10:03 AM

$rate_t = $rate_yes + $rate_no;

$abcd = round($rate_yes / $rate_t * 100);

Believe that's the correct idea now. Sorry like 5am over here, but i'll get it ;)

Dormilich

01-30-2010, 10:04 AM

is way better :)

Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.