ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> php-db
php-db
Re: [PHP-DB] figures question
by Joe Nilson Zegarra Galvez other posts by this author
Sep 27 2003 1:44PM messages near this date
[PHP-DB] figures question | [PHP-DB] Showing Average Visitors Per day
I think that you want to round the number, and yes, you can do it, How?,
well, by example

//Your Number from the DB
$number=10.2599999;

//Apply the round function to show only two decimals
$new_number=round($number,2);

//The result 10.26
echo $new_number;

Regards

Nilson

El sáb, 27 de 09 de 2003 a las 08:31, JeRRy escribió:
>  Hi,
>  
>  I have in my database a total value which looks like
>  this.
>  
>  0.00000
>  
>  If the figure is more than 9.99999 it goes to 10.00000
>  and so on..  The first 2 digits after the . is cents
>  and the following is part of a cent.
>  
>  So it appears in the database for example like 7.51234
>  .. But I want to display it on a PHP page as 7.51 and
>  forget the remaining digits.  Is it possible?  I want
>  to leave the digits in place on the database but have
>  the output as the dollar value and 2 cent values.
>  
>  Like This:
>  
>  If under $10
>  
>  $9.75
>  
>  If over $10
>  
>  $10.75
>  
>  If over $100
>  
>  $100.80
>  
>  and so on, is it possible?
>  
>  Thanks!
>  
>  http://search.yahoo.com.au - Yahoo! Search
>  - Looking for more? Try the new Yahoo! Search

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Thread:
=?iso-8859-1?q?JeRRy?=
Joe Nilson Zegarra Galvez

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved