I want to show a number from a database in the format x,xxx.00 in a
textfield, then if it is changed by the user I want to post the value of the
number to a decimal field. However, once you number_format the number it
becomes a string, and numbers like 3,379.90 give a value of 3 when posted to
]
o.ukcc:
Subject: [PHP-DB] number_format
problem
On Wed, 5 Nov 2003, Dillon, John wrote:
I want to show a number from a database in the format x,xxx.00 in a
textfield, then if it is changed by the user I want to post the value of the
number to a decimal field. However, once you number_format the number it
becomes a string, and numbers like
Great answer... One question though, how would you convert it back to
X,xxx.00 format??
Thanks
Aleks
-Original Message-
From: Peter Beckman [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 05, 2003 10:48 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] number_format problem
On Wed
On Wed, 5 Nov 2003, Aleks @ USA.net wrote:
Great answer... One question though, how would you convert it back to
X,xxx.00 format??
number_format($variable,2);
---
Peter Beckman
From: Dillon, John [EMAIL PROTECTED]
I want to show a number from a database in the format x,xxx.00 in a
textfield, then if it is changed by the user I want to post the value of
the
number to a decimal field. However, once you number_format the number it
becomes a string, and numbers like
From: [EMAIL PROTECTED]
could you cast as a float/double before inserting? $number = (double)
$string;
don't know what would happen to the comma, but i assume it would just get
removed??
Everything after and including the first non-number character would be
dropped.
So $12,000.34 would end
From: Peter Beckman [EMAIL PROTECTED]
On Wed, 5 Nov 2003, Dillon, John wrote:
I use this:
$x['funds'] = (int)preg_replace(/[\$,]/,,$x['funds']);
where $x['funds'] contains something like $3,249,555.32, and the end
result is an int of 3249555. I drop the cents... you want to keep
]
rter.netSubject: Re: [PHP-DB] number_format
problem
11
From: [EMAIL PROTECTED]
sweet. thanks for hte correction. i try, sometimes i fail. :)
But trying is half the battle. GI JOE!
---John Holmes...
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
10 matches
Mail list logo