Convert into a price

Discussion in 'PHP' started by webboy, Apr 22, 2009.

  1. #1
    Hi all ,

    Just some quick help

    I have a price in a mysql row with a value of 33399 and wish to output it on the screen as a price like 333.99

    the field type is a decimal

    what could i do as as the number_format dose not do what i want it to do
     
    webboy, Apr 22, 2009 IP
  2. javaongsan

    javaongsan Well-Known Member

    Messages:
    1,054
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #2
    select cast(price as numeric(18,2)
     
    javaongsan, Apr 22, 2009 IP
  3. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #3
    Bohra, Apr 22, 2009 IP
  4. webboy

    webboy Peon

    Messages:
    109
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    opps that did not work

    I have

    $quary="SELECT cast([price filed name] as Numeric(18,2)) , ID";
     
    webboy, Apr 22, 2009 IP
  5. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #5
    number_format($price / 100)
     
    SmallPotatoes, Apr 22, 2009 IP