Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display int as Money value (with decimal) 1

Status
Not open for further replies.

NickyJay

Programmer
Sep 1, 2003
217
GB
Hi guys, posting again already!

I am able to output the value of an item to screen no problems, the value is currentyl stored as an int in the database (not my choice but i have to keep it that way!)

The field is called "price" and stores values such as 699, 1496, etc, and i want to be able to display each as for example £6.99, and £14.95 - how do i format the output? I have tried using
Code:
<?php echo "£" . number_format($row_frying['price'],2); ?>
this outpust my value as £6,99.00 - not quite what i wanted!

How do i get rid of the .00 and put the decimal place before the last 2 digits from my db value?

Thanks!
 
Hi

There you are just formating the integer. You must divide it yourself with 100, no formatting function will do tjat automatically, because that step does not belong to the formatting task.
Code:
<?php echo "£" . number_format($row_frying['price'][red]/100[/red],2); ?>

Feherke.
 
Hiya Feherke,
thanks for responding so quickly :)

You're a gem - that worked perfectly - i understand it too - which is the bonus!!

Have a star x

Nicola
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top