So I hava a problem. On client side users insert theris data in textbox, radio in textarea. All number of input is stored in hidden type, sove php script on my server side knows how many input does it has. Sometimes there is just 20 inputs, sometimes 25 or 30, so the holl stuf is daynamic.
I have two questions: 1. How on server side dynamic generate variables and use them as $input1, $input2 and os on. 2. Let's say that I have somehow managde first problem so my second question is how to make query which sometimes uses only 20 parameters, sometimes 25 and so on. I don't wanna use arrays and tables;
I stareted php code:
for($i=1;$i<=$num; $i++){ //I get num from a hidden type
${"question".$i}="j";
if(isset($_POST["${"question".$i}"])){
${"question".$i}=$_POST[${"question".$i}];
echo question1; //this doesn't work but I want make created variables
//to use like this
}
else
{
echo "You have error with reading ".$i." question";
}
}
Why would you like to use the variables like this? If the input is dynamic use it like an array! -> Easier and cleaner.
There is good example how to handle a dynamic array input: Post array from html to php
Change echo question1;
by echo $question1;
(append $ symbol before your var name)
Or in dynamic way:
echo ${"question" . $i}