Jump to content

[SOLVED] formatting echo strings


tommy445

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

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.