[PHP] Array scanning stops by itself before reaching the end.

2002-02-10 Thread Raúl Sánchez T .

I got this stupid problem:
I create an HTML list of inputs: input name=Answer[] type='checkbox'  that 
stretches to some 25 elements.

When I try to read the values (on or off) with the code below, PHP won't read past 
the 8th. element and says it's found an undefined variable (which is $x). No matter 
what I do, it's always the 8th. element.


for($x = 1; $x = ($TotalAnswers); $x++)
{
 echo($Answer[$x]);
}

Anyone has a prompt solution? I'm getting desperate.
Thanks, Pepinho.



Re: [PHP] Array scanning stops by itself before reaching the end.

2002-02-10 Thread Bogdan Stancescu

Are you actually checking more than eight checkboxes? Otherwise you don't _get_ the 
ones which are unchecked at all - that's the way it works. The ideal way to do this - 
if you have to do it with arrays - is to walk
$Answer and check WHAT'S in there, rather than IF there is something in there. This 
obviously assumes you're setting distinct values for the checked checkboxes in HTML.

Anyway, the first thing to try is to set more than eight checkboxes in HTML and see if 
you get the error at different indexes.

HTH

Bogdan

Raúl Sánchez T. wrote:

 I got this stupid problem:
 I create an HTML list of inputs: input name=Answer[] type='checkbox'  that 
stretches to some 25 elements.

 When I try to read the values (on or off) with the code below, PHP won't read 
past the 8th. element and says it's found an undefined variable (which is $x). No 
matter what I do, it's always the 8th. element.

 for($x = 1; $x = ($TotalAnswers); $x++)
 {
  echo($Answer[$x]);
 }

 Anyone has a prompt solution? I'm getting desperate.
 Thanks, Pepinho.


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