Jump to content

[SOLVED] number formatting


tommy445

Recommended Posts

how do i decimal, comma, and $ format numbers called from mysql displayed in table cells using php.  This is the call script

 

<? echo $row['table_primary']; ?>

 

and this is the formatting script sample

 

<?php $value = 123456789;

echo number_format($value);

?>

 

How do I replace the $value=123... with my call script?  Thanks

 

Javascript don't seem to work because the number is being echo'd.

Link to comment
https://forums.phpfreaks.com/topic/148495-solved-number-formatting/
Share on other sites

From the manual:

Note: The function money_format() is only defined if the system has strfmon capabilities. For example, Windows does not, so money_format() is undefined in Windows.

Are you running this on a Windows host?

 

And what's up with:

echo money_format(table_primary);

It's not even a variable...

And lastly...we can't smell your problem, so please tell us what is going wrong and use the php code tags....

OK,

 

I have successfully called data (numbers) from the data base using

 

<? echo $row['table_primary']; ?>

 

My problem is that javascript will not format the numbers unless its in a textbox.

 

How do I format the echo string to show decimals and commas. 

 

This must be complex as i see similar questions that went unresolved.  Thanks for attempting.

 

Okay, well the piece of code that you gave us is wrong...

You might want to check that out before writing of money_format...

 

First,you haven't specified a variable because

<? echo money_format(table_primary) ?>

table primary is not a variable.

 

Secondly, you haven't specified a conversion character....

<? echo money_format('%i', $row['table_primary']) ?>

 

Read the manual!!

http://www.php.net/money_format

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.