advanced database entry

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
amdorsey
Forum Newbie
Posts: 19
Joined: Mon Dec 06, 2004 2:46 pm

advanced database entry

Post 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!
fractalvibes
Forum Contributor
Posts: 335
Joined: Thu Sep 26, 2002 6:14 pm
Location: Waco, Texas

Post 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
amdorsey
Forum Newbie
Posts: 19
Joined: Mon Dec 06, 2004 2:46 pm

Post 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?
fractalvibes
Forum Contributor
Posts: 335
Joined: Thu Sep 26, 2002 6:14 pm
Location: Waco, Texas

Post by fractalvibes »

Is "A" always = 167? and so forth for the other vars...

fv
amdorsey
Forum Newbie
Posts: 19
Joined: Mon Dec 06, 2004 2:46 pm

Post by amdorsey »

Yes, All 4 retain the same static values.
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

Post by lostboy »

concatenate the values pairs into one value (A-167). At the server, explode the results and do your stuff....
Post Reply