|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Formatting Field to numeric
How can I Format a numeric field, to be show in the web with the Commas,, Ex.. I have a numeric Field in MySql, the field is Amount and I declare it like Decimal 14,2.. I type the value 125000 in the field and when I print the value in the site, it is show without the numeric format, or currency... I want this so. : US $125,000.00, How can i do this...
I don't know if the type field is wrong...(decimal) |
|
#2
|
|||
|
|||
|
PHP Code:
__________________
__________________________________________________ _ Wil Moore III, MCP | Integrations Specialist | Senior Consultant Are You Listed...? | DigitallySmooth Inc. |
|
#3
|
|||
|
|||
|
<?
$host = "localhost"; $username = "mailcrea_than"; $password = "than"; $dbname = "mailcrea_loto"; $connection = mysql_connect("localhost", "mailcrea_than", "than"); $db = mysql_select_db("mailcrea_loto"); $resultado = mysql_query("SELECT lploto FROM parametros");// WHERE id = '1'"); $row = mysql_fetch_array($resultado); while ($row) { print "<table border=0>"; print "<td width=\"20%\">"; print "<div align=\"center\"><font color=\"0000ff\" face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"6\">"; // I WANT TO PRINT THIS VALUE FROM THE TABLE WITH THE COMMAS, BUT IT RETURN ME AN ERROR. HOW I CODE IT.. THE VALUE IS IN LPLOTO, IT IS A TABLE FIELD.. print ("$row[lploto]"); print "</font></div>"; print "</td>"; print "</tr>"; print "</table>"; $row = mysql_fetch_array($resultado); } ?> |
|
#4
|
|||
|
|||
|
PHP Code:
|
|
#5
|
|||
|
|||
|
Also, you could have done this:
PHP Code:
|
|
#6
|
|||
|
|||
|
Or
PHP Code:
|
|
#7
|
|||
|
|||
|
your code doesn't work ....
the lploto is a field of the table and it have this value "6000000.00" in this format, without the commas, and I want to print it with the commas...6,000,000.00, like this.... I use this code you gave me but, don't give me the commas, and I was trying to use the Format_number, in this way, but, it is wrong, because it return me an error. print ("Format_number $row[lploto,2]"); |
|
#8
|
|||
|
|||
|
PHP Code:
try it this way.
__________________
-- Jason |
|
#9
|
|||
|
|||
|
HA, now look who is quick... seems to be you Taelo.
|
|
#10
|
|||
|
|||
|
haha,...I gotcha! :P
|
|
#11
|
|||
|
|||
|
Yeah, I can't keep up anymore
![]() |
|
#12
|
|||
|
|||
|
what means this comments?
|
|
#13
|
||||
|
||||
|
Nestorvaldez, you've copied the code incorrectly. You have:
PHP Code:
which prints a string. What you should have is: PHP Code:
which executes the function number_format() on the value $row['lploto'] and displays two decimal points. The rest of the thread was in reference to an earlier post in which laidbak responded very quickly to a thread Taelo was watching. Try replacing your code with the exact code Taelo provided (and which I've pasted in here again) and see if that helps. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Formatting Field to numeric |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|