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++)
{
$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++)
{
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