I want to store a price for an item in decimal in MySQL.
How would I have to format the price in order to store in in the db?
number_format($number, 2, ".", "");
Or if you want the commas in it, you can use this one:
number_format($number, 2, ".", ",");
Check out number_format() at PHP.net
Mark Byers is correct; you shouldn't need to modify the data before sending it to mysql.
alter table foo change price price decimal(10,2) not null default 0
If your price column is currently an int, you will not lose data with this query.
For example, a value of 10 will be updated to 10.00, or a value of 5125 will be updated to 5125.00, etc.