Page 1 of 1

advanced database entry

Posted: Mon Dec 06, 2004 7:33 pm
by amdorsey
Heres the scenerio.
I have 4 check boxes (r1, r2, r3, r4)

$r1 = A
$r2 = B
$r3 = C
$r4 = NY

I then have a hidden field $region (to collect values to be entered into database)

Code: Select all

<input name="region" type="hidden" value="<?php echo ("$r1 $r2 $r3 $r4");?>">
So $region is entered into the database. easy.

THAT WORKS FINE. The tricky part.

I have a second set of values that needs to be calculated at the same time.

$r1 also = 167
$r2 also = 61
$r3 also = 24
$r4 also = 12

I then have another hidden field called $quanity

Code: Select all

$quanity = ("$r1 + $r2 + $r3 + $r4");
which returns the calculated value, so quanity = 86, or whatever the sum of the checkbox values is.

Lots of info, confusing?
Masters go to Work!

Thanks for any help at all!

Posted: Mon Dec 06, 2004 8:11 pm
by fractalvibes
Rename one set of your $r1 - $r4 form fields...it makes no sense as it is...
is $r1 = A or $r1 = 167? You cannot have it both ways....makes no sense!

fv

Posted: Mon Dec 06, 2004 8:15 pm
by amdorsey
Thats what I mean. I am looking for a way to have 1 form element (the checkbox) determine 2 different values. It holds the value of "A" as well as the value "167" Do I use some knid of array or something?

Posted: Mon Dec 06, 2004 9:07 pm
by fractalvibes
Is "A" always = 167? and so forth for the other vars...

fv

Posted: Mon Dec 06, 2004 10:59 pm
by amdorsey
Yes, All 4 retain the same static values.

Posted: Tue Dec 07, 2004 12:45 pm
by lostboy
concatenate the values pairs into one value (A-167). At the server, explode the results and do your stuff....