[PHP] *arrays/evaluating - ! urgent !

2002-12-17 Thread Alexey Lysenkov
Hello,
another newbie here.

Here is a loop:

for($f=0;$fcount($frage5);$f++){
$ff = $f+1;
echo(tr\n);
echo(td align=\right\ valign=\top\$frage5[$f]/td\n);
for($h=0;$hcount($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;$v7;$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;$icount($hersteller)+1;$i++){
  $tempQar = array_values(\$arq_5_.$i.);
  eval(\$tempQar=\$tempQar\;);
  for($a=0;$acount($frage5);$a++){
   $aa = $a+1;
   $tempVar = \$rq_q5_.$aa._.$i;
   eval(\$tempVar=\$tempVar\;);
   $tempQar[$a] = $tempVar;
  }
  for($v=0;$vcount($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




Re: [PHP] *arrays/evaluating - ! urgent !

2002-12-17 Thread Wico de Leeuw
Hiya,

I couldn't read you code really (i think you gotta look into it, eval is 
evil and really not nessacery here)

I suggest you look at this (piece) of code:

form action=?=$_SERVER['PHP_SELF']? method=post
input type=text name=text value=?=@$_REQUEST['text']?br /
select name=select
? for ($x = 0; $x  10; ++$x) { ?
option ?=@$_REQUEST['select'] == $x ? 'selected 
' : ''?value=?=$x?value_?=$x?/option
? } ?
/select
br /
input type=submit
/form

Gr,

Wico


At 17:52 17-12-02 +0100, Alexey Lysenkov wrote:
Hello,
another newbie here.

Here is a loop:

for($f=0;$fcount($frage5);$f++){
$ff = $f+1;
echo(tr\n);
echo(td align=\right\ valign=\top\$frage5[$f]/td\n);
for($h=0;$hcount($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;$v7;$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;$icount($hersteller)+1;$i++){
  $tempQar = array_values(\$arq_5_.$i.);
  eval(\$tempQar=\$tempQar\;);
  for($a=0;$acount($frage5);$a++){
   $aa = $a+1;
   $tempVar = \$rq_q5_.$aa._.$i;
   eval(\$tempVar=\$tempVar\;);
   $tempQar[$a] = $tempVar;
  }
  for($v=0;$vcount($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



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