473,385 Members | 1,311 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to display integer data as currency USD

40
Using MySQL to store data that is in integer form. Need to display data as USD (such as $678,321 for the integer value 678321).

Do I use PHP to do this or straight HTML? I have an HTML Form right now to display the data as it is formatted in MySQL.

TIA,

jej1216
Jul 3 '07 #1
6 4042
maybe try
[PHP]echo "$", $your variable to get the integer;[/PHP]
that will echo $678321
or if there is loads of numbers you want it doing to
[PHP]while($row = mysql_fetch_array($result))
{
echo "$" .$row['thesqltable'].
}

[/PHP]
Jul 3 '07 #2
kovik
1,044 Expert 1GB
number_format()

Expand|Select|Wrap|Line Numbers
  1. echo '$' . number_format($price, 2, '.', ',');
There is also money_format(), but it doesn't work on all servers (Windows in particular).
Jul 3 '07 #3
pbmods
5,821 Expert 4TB
MySQL also has its own FORMAT() function.
Jul 4 '07 #4
jej1216
40
Thanks, all.

In general, is it better practice to do the formatting in PHP or in MySQL?

Or does it make any difference?

It's a small table, so I'm not too concerned with execution time.

- jej1216
Jul 4 '07 #5
kovik
1,044 Expert 1GB
MySQL should have the raw numbers.
Jul 4 '07 #6
jej1216
40
Thanks - I stored the raw numbers in MySQL and used the formatting code for PHP, as suggested. Works like a charm.

Thanks again,

jej1216
Jul 5 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Not Me | last post by:
Hi, I have a table with a currency field, which is displayed via a form. If I open a query which displays this field (using the forms!myform.field notation) that field displays as though it's...
10
by: Peter Piper | last post by:
A Quick question if someone could help, im sure this has been asked before, but googling is getting me now where slowly. Is it possible to get an unsigned 32 bit integer field in Access. Im...
0
by: M. David Johnson | last post by:
I cannot get my OleDbDataAdapter to update my database table from my local dataset table. The Knowledge Base doesn't seem to help - see item 10 below. I have a Microsoft Access 2000 database...
2
by: AMDRIT | last post by:
Hello Everyone, I would like to format the Display Members of a combobox's datasource. Is there a way to apply a format without subclassing the original datasource? For example, given a list of...
5
by: Nonoize | last post by:
Hi all, Really dumb question but I don't know how to resolve it. Looked in help and evry book I have. I have a table where the primary key was set as an Integer and its reached over 140K...
5
by: Akaketwa | last post by:
guys help me on this rather nubish question.I have created a new data type in java and i also want to create a new data type object in db2 that will store the money data object. The money...
2
by: Mikus Sleiners | last post by:
I have a control - textBox1 that is binded to objects propery - "Currency" and another control - textBox2 (read only) that is also binded to same propery. Now, i have a situation where textbox1...
5
by: eric.goforth | last post by:
Hello, I have some xml data that look like: <currencysummary rec_count="16"> <currency> <currency_description>$</_currency_description> <currency_code>1</_currency_code> </currency>...
1
by: sunnyluthra1 | last post by:
Hi Everyone, I am working on a piece of code, that displays the properties(Name, Datatype, size & Description) of the table in the database. Now I want to further Enhance the code. I Have created...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.