Jump to content

Recommended Posts

i have placed an echo string in a table however i am unable to format the number with commas and decimals.

 

Java functions don't seem to work and I don't understand how to apply the number format form the manual... please help. 

 

Here is the echo string:

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

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/148537-solved-formatting-echo-strings/
Share on other sites

results from

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

returns 1000

 

results from

<? echo $row['client_primary_job']; printf ("%01.2f", $client_primary_job)?>

returns 10000.00

 

The decimal is o.k. but what's up with the extra zero to the number.?

 

Any ideas?  thx

$row['client_primary_job']    AND    $client_primary_job  are two different variables...

 

Anyway, I don't know what's wrong because this works for me:

 

    $client_primary_job = 1000;
    printf ("%01.2f", $client_primary_job)
?>

 

output 1000.00

O.K. i had to declare variable $client_primary_job = $row['client_primary_job']; from my mysql query.  Then i used <?php print ("%01.2f, $client_primary_job) ?>

to get my decimals.

 

Two things.  Do I now have to do this for all 60+ fields in the table? or is there a global way of doing it.  And, how am I to get the comma in that string?

 

thanks again.

O.K. i had to declare variable $client_primary_job = $row['client_primary_job']; from my mysql query.  Then i used <?php print ("%01.2f, $client_primary_job) ?>

to get my decimals.

 

Two things.  Do I now have to do this for all 60+ fields in the table? or is there a global way of doing it.  And, how am I to get the comma in that string?

 

thanks again.

 

ken's answer works, I also answered in your other thread with the same solution...

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.