I have a form woth 32 fields and i want to check if this fields has values entered.
So, i think to use a for loop and to constract the checking value dynamically.
the posted fields has the same name except two characters - the numbers that defines the field indivitually.
i.e. 10-0?-001-q?
I use the following script to generate the id's of posted fields.
Code: Select all
for ( $i = 1; $i <= 32; $i ++) {
if ($i > 9) {
$source="10-".$i."-001-q".$i;
}else{
$source="10-0".$i."-001-q".$i;
}After that ... and there is the problem.... i create a string as follows
Code: Select all
$constract= "(isset(\$_POST['".$source. "'])) ? \$_POST['".$source."'] : \"\" ;" ;With that way i suppose that i can check if the field has data in it or not.
Code: Select all
if (!$constract) {
echo "no data for field:" . $source;
}else{
echo "Field: " . $source . " has the following data: " . $constract;
}The problem here is that $constract variable does not store the value of the posted field but stores the hole string ....
Code: Select all
(isset($_POST['10-01-001-q1'])) ? $_POST['10-01-001-q1'] : "" ;Code: Select all
(isset($_POST['10-02-001-q2'])) ? $_POST['10-02-001-q2'] : "" ;.
.
.
I want to store the value of the posted field ..... and not the hole string ...
Can anyone help me ????
Thanks
sorry for my english
