loop problem [solved]
Posted: Mon Apr 10, 2006 1:00 pm
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello folks!
I´m a beginner at this php stuff programming. Could anyone explain me why this variable $z at second loop never change? $z = 0 forever at the second loop, but at the first $z works fine...
Why php don´t allow you to use a variable outside of the loop?
Thank you guys!Code: Select all
$i = 1;
$z = 0;
while ($z < count($arrTipos)) { //first loop
while ($row = mysql_fetch_assoc($rs)) { //second loop
print_r($row);
if ($i <= 2) {
if ($row["idTipo"] == $arrTipos[$z]["idTipo"]) {
echo $z."-".$row["idTipo"]."<br />";
$i = $i + 1;
}
} else {
//next($arrTipos);
$i = 1;
}
}
//echo $arrTipos[$z]["Tipo"]."<br />";
$z = $z + 1;
}feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]