Re: Do two lists in a while statement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/21/07, Richard Kurth <richardkurth@xxxxxxxxxxxxxx> wrote:

On 4/21/07, Richard Kurth <richardkurth@xxxxxxxxxxxxxx> wrote:
>
> On 4/21/07, Richard Kurth <richardkurth@xxxxxxxxxxxxxx> wrote:
> > How can I do something like this in the same while statement. This
> > does not work while (list(,$possible) = each($possiblefields)
> > list(,$possibleview) = each($possiblefieldsdiscription)){
> > }
> >
>
> What about using && ?
>
>
> while (list(,$possible) = each($possiblefields) &&
> list(,$possibleview) = each($possiblefieldsdiscription)){
> }
>
>
> Doesn't && mean if both variables are TRUE.

Yes, isn't that what you wanted?
Normaly a while checks also if it was TRUE. now it checks if both are TRUE..
If you only require one of both to be TRUE, use || instead of &&.


I am trying to fill in the drop down box in the script below but it is not
working it is only giving me the $possibleview data but not the
$possible data
Hmm strange, i don't see any real error, so to test if it's a problem
with the while loop, you could assign the backward order. So the code
would look like the one below. Please test it, and see if you still
get the same problem, or if you get $possible now instead of
$possibleview.

Tijnema


$fieldnumber = 0;
          while (list(,$field) = each($fields)){
              echo "    <TR>\n";
              echo "        <TD><SELECT NAME=fieldorder[]>\n";
              reset($possiblefields);
                               reset($possiblefieldsdiscription);
              $anyselected = '';

              while (list(,$possibleview) =
each($possiblefieldsdiscription && list(,$possible) =
each($possiblefields))){


                  $selected = @(($fieldorder[$fieldnumber] == $possible) ?
'SELECTED' : '');
                  if ($fieldnumber >= count($fieldorder) &&
!$anyselected){
                      $selected = 'SELECTED';
                  }
                  echo "<OPTION value=\"$possible\"
$selected>$possibleview</OPTION>\n";
              }
              echo "        </SELECT></TD>\n";
              echo "        <TD>$field</TD>\n";
              echo "    </TR>\n";
              $fieldnumber++;
          }

--
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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux