Hi - hope I'm making sense with this....
I'm trying to get my PHP script to check if a variable $r passed on by a POST form exists, and execute the appropriate action (i.e. if $r exists {print} else {print something else} - standard stuff).
$r constitutes of "$r" + two other values stored in the looping $x amd $y (I'm looping with two for arguments).
In the URL, I can see that $r.$x.$y=on
Now then for the questions:
- How do I assign the 2 variables $x and $y to $r to produce a looping $r as long as the $x and $y for loop is valid? I know how to do it with one variable, but it doesn't seem to handle that I'm assigning 2.
- Am I wrong in trying to execute an if..else inside a for loop?
- If not - how do I check in PHP for the existence of a checked radio button?
I'd really appreciate some help with this..!
Kind Regards,
chris
<?php
// $x = number of questions
// $y = number of answer alternatives
print htmlentities ('<form action="');
print $php3.('.php3');
print (' method=POST>');
print '<br>';
print htmlentities ('<font face="arial, helvetica, sans-serif"; size="+1"><b>');
print '<br>';
print $quiztittel;
print htmlentities ('</b></font>');
print '<br>';
for ($a=1; $a<=$x; $a++)
{
$helper2 = "q".$a;
print $$helper2;
print htmlentities ('<br>');
print '<br>';
for ($b=1; $b<=$y; $b++)
// This is where I'm trying to assign a check if a looping variable $r ($r="r".$x.$y) exists, if it does execute:
{
$helper = "q".$a."svaralt".$b;
print htmlentities ('<input type="radio" name="q');
print $a.'" value="1">';
print htmlentities ('<br>');
print '<br>';
print htmlentities ('<i>');
print '<i>'.$$helper.'</i>';
print htmlentities ('</i>');
print '<br>';
} else {
$helper = "q".$a."svaralt".$b;
print htmlentities ('<input type="radio" name="q');
print $a.'" value="0">';
print htmlentities ('<br>');
print '<br>';
print htmlentities ('<i>');
print '<i>'.$$helper.'</i>';
print htmlentities ('</i>');
print '<br>';
}
}
?>