Jump to content

problem with for loop


smoky989

Recommended Posts

my 2nd for loop is only executing once.  When I echo $num_results2 it shows 9 which is how many times the loop should execute.  Any suggestions?

 

$result = mysql_query("select DISTINCT team_name from order_players order by team_name ASC;");

$num_results=mysql_num_rows($result);

 

if (!$result)

{

do_html_header("Problem:");

echo "The database server is down.  Please try again later!";

do_html_footer();

exit;

}

else if(mysql_num_rows($result)>0)

{

echo "<table border=0 width=100% border=0 cellpadding=1 cellspacing=1><tr>";

 

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

{

$row=mysql_fetch_array($result);

$team_name = stripslashes($row["team_name"]);

 

echo "<td width='33%'>";

echo "<div align='center'><u><strong>".$team_name."</strong></u></div>";

 

$result2 = mysql_query("select * from order_players where team_name = '$team_name' order by last_name ASC;");

$num_results2=mysql_num_rows($result2);

 

echo $num_results2;

 

for($z=0; $z < $num_results2; $z++)

{

echo "hi<br>";

$row2=mysql_fetch_array($result2);

$first_name = stripslashes($row2["first_name"]);

$last_name = stripslashes($row2["last_name"]);

$player_id = stripslashes($row2["player_id"]);

 

echo "<input type='checkbox' name='players[]' value='".$player_id.">".$last_name.", ".$first_name."<br>";

}

echo "</td>hmmm";

}

}

echo "</tr></table><br>";

 

echo "<input name='season_id2' type='hidden' value='".$season_id."'>";

echo "<input type=button onClick=location.href='transactions.php' value='Move Player(s)'>";

 

 

Link to comment
https://forums.phpfreaks.com/topic/151663-problem-with-for-loop/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.