Hello,
another newbie here.

Here is a loop:

for($f=0;$f<count($frage5);$f++){
    $ff = $f+1;
    echo("<tr>\n");
    echo("<td align=\"right\" valign=\"top\">$frage5[$f]</td>\n");
    for($h=0;$h<count($hersteller);$h++){
     $hh = $h+1;
     $varName = "q5_".$ff."_".$hh;
     echo("<td align=\"center\" valign=\"middle\"><select
name=\"$varName\">\n");
     $tempQar = "array_values(\$arq_5_".$hh.")";
     eval("\$tempQar=\"$tempQar\";");
      for($v=0;$v<7;$v++){
       if((int)$tempQar[$f] == $v){
        $sel = "selected";
       }else{
        $sel = "";
       }
       echo("<option value=\"$v\" $sel>$v</option>\n");
      }
     echo("</select>\n</td>\n");
    }
   }

Arrays hersteller as well as frage5 are set manually, so they are okay.They
are printing out okay as well.
The logic is as follows - not to make (frage5*hersteller) variables, I
manually set 5 empty arrays with the names arq5_1, arq5_2 and
arq5_[hersteller], etc. Now, when the form is submitted and something is
being wrong with the input, it returns the form (practically, goes through
the whole html again) and sets the selected fields to the options, radios
and values already submitted. Supposed to be nice, so you correct only what
you did wrong.
What I am failing to achieve with this code, is keeping the options of the
selects in the manner they were selected when submitting. In the include,
which validates the input it works alright. Here is the code:

for($i=1;$i<count($hersteller)+1;$i++){
  $tempQar = "array_values(\$arq_5_".$i.")";
  eval("\$tempQar=\"$tempQar\";");
  for($a=0;$a<count($frage5);$a++){
   $aa = $a+1;
   $tempVar = "\$rq_q5_".$aa."_".$i;
   eval("\$tempVar=\"$tempVar\";");
   $tempQar[$a] = $tempVar;
  }
  for($v=0;$v<count($tempQar);$v++){
   if($tempQar[$v] == "0"){
    $frage5_count++;
   }
  }
}
if($frage5_count > 3){
 $varsOkay = false;
 $frage5warn = true;
}

If I put print_r($tempQar) after the second "for..." statement, it prints
out the array, which is alright - with every value submitted in its place.
But somehow, almost the same thing doesn't work in the main, so to say,
file. Could anyone help? Please? It's urgent.

Regards,
Alex



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to