How do I make a data entry of 5500 auto display as 5,500.00

3 posts by 2 authors in: Forums > CMS Builder
Last Post: March 29, 2011   (RSS)

By Codee - March 29, 2011

Inside CMSB in a products section, with regards to a price field: the client would like to enter just the digits into the database, but have the display use a numeric format with a comma and 2 decimal places.

for example, they enter 3587 into the price field...and the end user would see 3,587.00 (the $ sign can obviously be added with html).

or they enter 45667 into the price field and the end user sees 45,667.00 ?

Thanks!

Re: [Damon] How do I make a data entry of 5500 auto display as 5,500.00

By Codee - March 29, 2011 - edited: March 30, 2011

Thanks Damon! That coupled with the following code snippet works like a charm!

<?php if ($record['price']): ?>
<?php
$number = $record['price'];
setlocale(LC_MONETARY, 'en_US');
echo money_format('%(#10.2n', $number) . "\n";
?>
<br clear="all">
<?php endif ?>