Jump to content

Archived

This topic is now archived and is closed to further replies.

flashguy82

PRICE FIELD HELP!?

Recommended Posts

Hi, i'm having some trouble getting my price field right. I have set it as a "DOUBLE" field but it's very stupid ill give u an example this is ok "49.99" that will show up but say if i do this "49.00" the ".00" won't show up, it's only with 0's i have the problem also say i add this "49.50" it will show up as "49.5" does anyone know where i'm coming from? can anyone help me out with this?

Thanks -

Erik

Share this post


Link to post
Share on other sites
So when you try to update/insert it, it does that (takes all 0's off)? Give this a read: http://dev.mysql.com/doc/refman/5.0/en/data-types.html

Share this post


Link to post
Share on other sites
Hi, use the c style string commands to get a formatted answer.

check out sprintf in the php manual for more information

$price = 49.50;
$formattedPrice = sprintf("%01.2f", $price);
echo"$formattedPrice";

Share this post


Link to post
Share on other sites

×

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.