|
Posted by laredotornado@zipmail.com on 03/20/06 21:30
Hi,
I am grabbing prices from a database. Sometimes the price is NULL and
sometimes there's a floating point value. Using PHP 4, when I print
the price to my CSV file, I want the price, rounded to the second
decimal place if the pirce is non-empty, but nothing if the price was
empty.
This doesn't work (it prints out 0.00 if the price is empty), but right
now I have
$line =
sprintf("\"%s\",\"%s\",\"%s\",\"%s\",\$%2.2f,\$%2.2f,\"%s\",%d,\"%s\"\r\n",
$company,
$model_num,
$box_name,
$compatible_models,
$retail_price,
$price,
$description,
$max_yield,
$color);
How do I adjust the above to get my desired result?
Thanks, -
[Back to original message]
|