Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.