[PHP & MYSQL] Valuta in db plaatsen. 300.000 euro

Pagina: 1
Acties:
  • 207 views sinds 30-01-2008
  • Reageer

Onderwerpen


Acties:
  • 0 Henk 'm!

Verwijderd

Topicstarter
Ik wil in een mysql database een bedrag van 300.000 euro plaatsen.
Nu weet ik dat ik voor bedragen Float moet gebruiken.
350.555 werkt perfect maar 300.000 rond ie af naar 300

Hoe kan ik ervoor zorgen dattie toch 300.000 laat staan ?
Weet iemand dit toevallig ?

Acties:
  • 0 Henk 'm!

Verwijderd

iets met number_format() ofzo?

Acties:
  • 0 Henk 'm!

  • chris
  • Registratie: September 2001
  • Laatst online: 11-03-2022
wat bedoel je precies met 300.000? dit is vanuit MySQL gezien geen driehonderdduizend, maar 300 komma 000. MySQL werkt namelijk met de . (punt) als scheidingsteken. Je moet dus 300000 gebruik voor driehonderdduizend. Dus het bedrag zonder de punt.

Acties:
  • 0 Henk 'm!

Verwijderd

Float is eigenlijk ook kort voor floating point natuurlijk, waar Nederlanders drijvende komma zeggen.

Acties:
  • 0 Henk 'm!

Verwijderd

dus idd gewoon opslaan als 300000 of 300000.00 oid, en dan als je het uit de db haalt met numberformat omzetten naar de goede representatie ... :D

Acties:
  • 0 Henk 'm!

  • ACM
  • Registratie: Januari 2000
  • Niet online

ACM

Software Architect

Werkt hier

Voor valuta is trouwens het Decimal opslag type een goede keus.

Acties:
  • 0 Henk 'm!

Verwijderd

Topicstarter
ok bedankt ik snap het..

Acties:
  • 0 Henk 'm!

  • chris
  • Registratie: September 2001
  • Laatst online: 11-03-2022
uit de MySQL manual:
The NUMERIC and DECIMAL types are implemented as the same type by MySQL, as permitted by the SQL92 standard. They are used for values for which it is important to preserve exact precision,for example with monetary data. When declaring a column of one of these types the precision and scale can be (and usually is) specified;
The FLOAT type is used to represent approximate numeric data types. The ANSI/ISO SQL92 standard allows an optional specification of the precision (but not the range of the exponent) in bits following the keyword FLOAT in parentheses. The MySQL implementation also supports this optional precision specification. When the keyword FLOAT is used for a column type without a precision specification, MySQL uses four bytes to store the values. A variant syntax is also supported, with two numbers given in parentheses following the FLOAT keyword. With this option, the first number continues to represent the storage requirements for the value in bytes, and the second number specifies the number of digits to be stored and displayed following the decimal point (as with DECIMAL and NUMERIC). When MySQL is asked to store a number for such a column with more decimal digits following the decimal point than specified for the column, the value is rounded to eliminate the extra digits when the value is stored.
Pagina: 1