Forum Moderators: coopster

Message Too Old, No Replies

Decimals and Commas - Price Field

How do I add Decimals and a Comma to the PHP Output

         

antonio123

8:19 pm on May 13, 2009 (gmt 0)

10+ Year Member



Hello All!

I have a query below:

SELECT
distinct manufacturer_sku, id,
CONCAT('$',MIN(ABS(SUBSTRING_INDEX(sale_price,'$',-1)))) AS price
from products
where manufacturer_name = "manufacturers-name"
GROUP BY manufacturer_sku
ORDER BY id

Question 1:
How Do I add a comma if the price goes above $999.99?
Question 2:
How Do I add a decimal point at the end (like $999.99)?

I have the Price Field defined as "Decimal" in my MySQL database.

Please advise.

Thank you in advance.

Regards,

Antonio123

mooger35

8:23 pm on May 13, 2009 (gmt 0)

10+ Year Member



$formatted_price = number_format [php.net]($price,2);

antonio123

8:26 pm on May 13, 2009 (gmt 0)

10+ Year Member



Thank you mooger35! That is exactly what I needed!

mooger35

8:44 pm on May 13, 2009 (gmt 0)

10+ Year Member



You are welcome