Forum Moderators: coopster

Message Too Old, No Replies

Assigning a null value

Coding a missing radio button as missing

         

s9901470

2:46 pm on May 24, 2005 (gmt 0)

10+ Year Member



Hi

I have a set of radio buttons labelled 1-5 and a 'not selected' option which I have coded as 6. I later use responses of 1-5 to calculate a score, but at the moment the 6 is included in that score when it should really be excluded as null.

Is there a way to tell PHP that any values of '6' should be null, and to use '3' instead?

Any suggestions welcome.

cputek2k

2:52 pm on May 24, 2005 (gmt 0)

10+ Year Member



you could use...

if ($value == '6'){
$value = '3';
}

s9901470

3:57 pm on May 24, 2005 (gmt 0)

10+ Year Member



Many thanks! Is there a short-hand to apply this to all variables e.g. q1, q2 ... q100
?

jatar_k

4:31 pm on May 24, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



$maxq = 100;
$qc = 1;
while ($qc <= $maxq) {
if (${'q' . $qc} == 6) ${'q' . $qc} = 3;
$qc++;
}