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 5 of 5
  1. #1
    New Coder
    Join Date
    Aug 2009
    Posts
    95
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Need help returning value as decimal

    Trying to modify this code slightly to allow the returned value to be in decimal format.

    Code:
    $min=number_format(mysql_result($result,$i,"minutes"));
    In this instance, the value in the database is 40.5, but is returning as 41. What do I need to add to that line of code to get it to display correctly as 40.5?

  • #2
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Stop formatting it with the number_format function?

  • Users who have thanked MattF for this post:

    chibul (02-08-2010)

  • #3
    New Coder
    Join Date
    Aug 2009
    Posts
    95
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Tried that...changed it to
    Code:
    $min=(mysql_result($result,$i,"minutes"));
    and still nothing.

  • #4
    New Coder
    Join Date
    Aug 2009
    Posts
    95
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Nevermind...I'm a dolt. LOL

    Thanks!

  • #5
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    That should be:

    Code:
    $min=mysql_result($result,$i,"minutes");
    If it's 40.5 in the DB, and changing that line makes no difference, then the number is being rounded somewhere else.


    Edit: Just seen your other post. Pipped whilst composing the post.
    Last edited by MattF; 02-08-2010 at 01:57 AM.


  •  

    Posting Permissions

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