Hi all as you can probably see im having a nightmare at the moment with a particular project.
On a form i have a number of radio buttons named question1, question2, question3 ........ question n.
Now what Im trying to do is request the values stored in each of these variables. What Im tring to do is the following:
PHP Code:
$question=$_REQUEST['question']; /This is how many questions are in the form
for ($i=1;$i<=$questions;$i++) {
$t = $_REQUEST['question$i'];
}
What Im basically tring to do is request the values from the number of variables that are existing. However, the above doesnt seem to work and I have tried all different ways of coding it. Has anyone got any ideas?
Inside your for loop I think your variable that's set from the $_REQUEST is wrong, it should be question, not questions. I don't think you need to reference the counter inside the $_REQUEST either. These are merely suggestions as to what I saw wrong.
I think I may have explained that wrong. Inside the counter I am trying to extract the values stored in the variable question1, question2, question3, question ..... upto the total number of questions. I need a way so that in the for loop the value $t requests the question the $i corresponds to. Hope this explains a little better.
$t = "Questions: "; $question = $_REQUEST['question']; //This is how many questions are in the form
for($i=1;$i<=$question;$i++){ // your '$questions' has an S which did not match your veriable you set. $t .= $_REQUEST['question{$i}']; // To concatinate the $t vaiable, and the . befoier the =. if($i == $question){ $t .= "."; }else{ $t .= ", "; } }
Bookmarks