Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder sitNsmile's Avatar
    Join Date
    Dec 2009
    Location
    Charlotte, NC
    Posts
    358
    Thanks
    19
    Thanked 2 Times in 2 Posts

    Unhappy how to get percent out of 100%

    PHP Code:
    $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
    Last edited by sitNsmile; 01-30-2010 at 11:07 AM.

  • #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,471
    Thanks
    13
    Thanked 361 Times in 357 Posts
    a little math would be helpful … ask yourself, what exactly is represented by 100%? is it $rate_yes, $rate_no or something else.

  • #3
    Regular Coder sitNsmile's Avatar
    Join Date
    Dec 2009
    Location
    Charlotte, NC
    Posts
    358
    Thanks
    19
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by Dormilich View Post
    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 ?

  • #4
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,471
    Thanks
    13
    Thanked 361 Times in 357 Posts
    yea, I understand that, but your formula ain’t right.

  • #5
    Regular Coder sitNsmile's Avatar
    Join Date
    Dec 2009
    Location
    Charlotte, NC
    Posts
    358
    Thanks
    19
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by Dormilich View Post
    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% ?

  • #6
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,471
    Thanks
    13
    Thanked 361 Times in 357 Posts
    so you need to translate 10 / 17 into PHP code …

  • #7
    Regular Coder sitNsmile's Avatar
    Join Date
    Dec 2009
    Location
    Charlotte, NC
    Posts
    358
    Thanks
    19
    Thanked 2 Times in 2 Posts
    PHP Code:
    $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

  • #8
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,471
    Thanks
    13
    Thanked 361 Times in 357 Posts
    is way better


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •