Welcome Guest, Not a member yet? Register   Sign In
use string helper with currency
#11

[eluser]jedd[/eluser]
[quote author="Michael Nielsen" date="1235785694"]
Also this site is only for New Zealand residence. My goal was to be able to enter a numeric value in the form then before it's entered into the database by the controller have it add $ sign so I don't have to waste time on every entry by manually typing the $ sign.
[/quote]

Okay .. the thing is you don't want a non-numeric character (the '$') in your database column where you're storing the dollar amount. There are several reasons for this. First it breaks normalisation rules for schema design (well, it does). Then there's the problem of you not being able to force one of numeric (as darkhorse suggested using float or double) column types, which would give you another layer of data type validation at the time you insert into the DB. (If you have $ you are going to have to use a text type in the database.) Then there's the benefit of being able to do in-database math on the values in those records (with the $ present, you can't). Then there's the convenience of doing out-of-DB (but in your PHP code) math on the raw fields, without having to strip each $ from each figure as you go.

There's probably more .. Smile

I'm not sure what you mean by 'so I don't have to waste time on every entry by manually typing the $ sign'. On the form you would not require the dollar character to be entered at all. If this confuses your staff, get better staff Wink - or just put a $ sign before the text box to remind them it's a dollar field.


Messages In This Thread
use string helper with currency - by El Forum - 02-26-2009, 10:24 PM
use string helper with currency - by El Forum - 02-26-2009, 10:33 PM
use string helper with currency - by El Forum - 02-26-2009, 11:17 PM
use string helper with currency - by El Forum - 02-26-2009, 11:57 PM
use string helper with currency - by El Forum - 02-27-2009, 12:08 AM
use string helper with currency - by El Forum - 02-27-2009, 01:38 AM
use string helper with currency - by El Forum - 02-27-2009, 01:38 AM
use string helper with currency - by El Forum - 02-27-2009, 01:53 AM
use string helper with currency - by El Forum - 02-27-2009, 07:39 AM
use string helper with currency - by El Forum - 02-27-2009, 01:48 PM
use string helper with currency - by El Forum - 02-27-2009, 04:01 PM
use string helper with currency - by El Forum - 02-27-2009, 05:20 PM
use string helper with currency - by El Forum - 02-27-2009, 06:49 PM
use string helper with currency - by El Forum - 02-28-2009, 02:59 AM



Theme © iAndrew 2016 - Forum software by © MyBB