1 Reply Latest reply on Sep 19, 2007 2:06 AM by Günter Schenk

    Best way to store price


      Does anyone know what is the best way to store prices in MySQL, and then how to format it on the output page.

      Thanks in advance
        • 1. Re: Best way to store price
          Günter Schenk Level 4
          Hi Jose,

          that depends on your prices:

          a) if they will always be integer (e.g. 120000 EUR), store them in an INT(x) column (where x is the max. amount of digits), and use PHP´s "number_format" function to display them as e.g. (will show as 120.000) EUR

          b) if your prices will contain a decimal point (e.g. 12.99), the column could be defined as e.g. FLOAT(x,2) (where x is the max. amount of digits preceeding the decimal point, and 2 define a fixed amount of digits after the decimal point). In order to display those prices differently on a page, PHP´s "number_format" function has a variety of options, e.g. (will show as 12,99) EUR

          Günter Schenk
          Adobe Community Expert, Dreamweaver