Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Senior Member Seldimi's Avatar
    Join Date
    Dec 2002
    Location
    Kozani, Greece
    Posts
    488
    Member #
    409
    Hello all
    Long time no see, but hopefully i will be back in forum
    Recently i made a script for rating items, giving them rate from 1-10 but i got a slice problem.
    If 3 users rate an item for 4, 3, 3 the total ammount is 10 and the average goes at 10/3 = 3.33333333

    How can i make php display 2 digis like 3.33 or 1 digit 3.3, any ideas?

    Here is my code
    PHP Code:
    $total = ($vote_total/$vote_count); 
    $total = the average rate.
    $vote_total = sum of rates
    $vote_count = sum of user's rated
    - Webmaster's Planet . Greek Vortal For Webmasters ...
    - MyPortFolio - View My Creations

  2.  

  3. #2
    Senior Member Stylise's Avatar
    Join Date
    Jul 2005
    Location
    Mount Martha, Australia
    Posts
    229
    Member #
    10679
    round(float val, int precision)

    PHP Code:
    //output no decimals
    $total round($total0);

    //output one decimal
    $totalround($total1);

    //output two decimals
    $total round($total2);

    //and so on... 

  4. #3
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Alternatively, you could use the number_format function.

  5. #4
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,656
    Member #
    1234
    Liked
    137 times
    Long time no see!
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  6. #5
    Senior Member bluntknife's Avatar
    Join Date
    Jan 2003
    Location
    Bucks UK
    Posts
    288
    Member #
    451
    Wow, September 04, that's even longer than I was away for! :P

    Must be an influx of people finishing exams or something!

    Ollie
    Hardly the sharpest thing in the drawer.
    Design | Life | Outdoors | Ryukin Radio

  7. #6
    Senior Member Seldimi's Avatar
    Join Date
    Dec 2002
    Location
    Kozani, Greece
    Posts
    488
    Member #
    409
    Haha Yea its being loooooooooooooooooong time....
    Busy at school and forgot almost my "love" webmastering and my website..
    But i decided to return, hehe

    thanx for replies...
    - Webmaster's Planet . Greek Vortal For Webmasters ...
    - MyPortFolio - View My Creations


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:28 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com