On 05 August 2004 15:15, Jay Blanchard wrote: > [snip] > if($ans_three[$qzid] === 'None of the above' || $ans_three[$qzid] === > 'All of the above'){ if($ans_four[$qzid] === 'None of the above' > || $ans_four[$qzid] === 'All of the above'){ > $answers = rand(6,8); > > } > $answers = 5; > } > else{ > $answers = rand(1,4); > } > > However when I run it, it checks everything correctly until it has > answer three and four having 'All of the above' and 'None of > the above', > then it branches to $answer = 5, only. Why? > [/snip] > > Because $answers = 5; is the last check of $answers unless the else > statement is invoked. Try this... > > if($ans_three[$qzid] === 'None of the above' || $ans_three[$qzid] === > 'All of the above'){ if($ans_four[$qzid] === 'None of the above' > || $ans_four[$qzid] === 'All of the above'){ > $answers = rand(6,8); } elseif($ans_four[$qzid] !== 'None of the > above' || $ans_four[$qzid] !== 'All of the above'){
Ehhhrrrmmm -- that elseif () condition is always going to be true: logically, it's got to be not equal to one or other of the values. >From a quick glance at the code, I'd say just a straight else would do the job here, thus: if ($ans_three[$qzid] === 'None of the above' || $ans_three[$qzid] === 'All of the above') { if ($ans_four[$qzid] === 'None of the above' || $ans_four[$qzid] === 'All of the above') { $answers = rand(6,8); } else { $answers = 5; } } else { $answers = rand(1,4); } Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php