See changes below.

Cheers,
Rob.

On Sat, 2003-10-18 at 14:57, Jed R. Brubaker wrote:
> Hi! I am trying to loop through two different database calls with two for
> statements, one embedded in the other.
> 
>        for ($i; $i < $codeset_rows; $i++)

         for ($i = 0; $i < $codeset_rows; $i++)

>         {
>             $codeset_row = $this->database->fetch_array($codeset_query);
>             $codesys_query = $this->database->query("select
> codesys.codesys_index,
> 
> codesys.code_name,
> 
> codesys.code_value
> 
> from   codesys
> 
> where  codesys.codeset_ID = ".$codeset_row['codeset_ID']);
> 
>             $codesys_rows = $this->database->num_rows($codesys_query);
> 
>             for ($j; $j < $codesys_rows; $j++)

              for ($j = 0; $j < $codesys_rows; $j++)

>             {
>                 echo "Blah, blah, blah....";
>             }
> 
>         }
> 
> The current set up means that the first loop should cycle twice, and the
> second loop should cycle 6 times the first time and 2 times the second.
> 
> So here is the question: $j doesn't unset when the loop ends. So when it
> comes around the second time, $j still = 6 and since $codesys_rows = 2, it
> skips the loop. I can fix this by putting an
> if ($j)
>     {unset($j);}
> right before the second loop. However, it seems that there should be some
> more efficient way to do this.
> Ideas?
> 
> Thanks!
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

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

Reply via email to