Page 1 of 1

insert form wizard: how to concatenate two fields into one?

Posted: 2011-03-08 12:12
by antonio
Hi all,
I have an insert form on a page and I have two fields that allow the user to enter a number (set as varchar in the db) and a decimal (set as varchar in the db).
I need to concatenate those two fields into one in the "number,decimal" format; then, I need to insert this field in his db field.

Is there a way to do this with ADDT?
Or, is there a way toworkaround this problem in another way? basically I need to force the user to enter the number with 2 decimals.

examples:
these are values that will be accepted:
100,20
12,50
3,50
1000,50

thesen are values that will not be accepted:

100,2
12,5
3
1000

Is there a solution?

TIA

antonio

Re: insert form wizard: how to concatenate two fields into o

Posted: 2011-03-09 17:52
by Fred
Hi Antonio,
Quick question... Why do you store the data in separate fields and as varchar?

I would simply go for float(6.2) or whatever you want it to be.
Then when the user enters the data it is irrelevant if he enters 3 or 3.00. The data in the db will always be properly formatted.

Now when you want to display the data you might end up with 3 instead of 3.00 but you can format the value with php
<?php echo number_format($row_rs_cur_tot['cur_hrs'],2); ?>

Re: insert form wizard: how to concatenate two fields into o

Posted: 2011-05-06 17:46
by jlig
I always use Decimal for storing Dollar amounts in MySQL.. (Type = Decimal) (Length = 10,2)

- See this link for a good description & image: http://jeffmigliore.com/