Jump to content


Photo

PRICE FIELD HELP!?


  • Please log in to reply
2 replies to this topic

#1 flashguy82

flashguy82
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 21 September 2006 - 09:30 PM

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

#2 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 21 September 2006 - 09:35 PM

So when you try to update/insert it, it does that (takes all 0's off)? Give this a read: http://dev.mysql.com...data-types.html

#3 warewolfe

warewolfe
  • Members
  • PipPipPip
  • Advanced Member
  • 57 posts
  • LocationOtago, NZ

Posted 21 September 2006 - 10:59 PM

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";






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users