smoky989 Posted March 29, 2009 Share Posted March 29, 2009 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 More sharing options...
smoky989 Posted March 29, 2009 Author Share Posted March 29, 2009 fixed: had to add a single quote to close out the value attribute in my checkbox. Link to comment https://forums.phpfreaks.com/topic/151663-problem-with-for-loop/#findComment-796459 Share on other sites More sharing options...
Maq Posted March 29, 2009 Share Posted March 29, 2009 fixed: had to add a single quote to close out the value attribute in my checkbox. Can you mark as [sOLVED] then, and use tags next time. Link to comment https://forums.phpfreaks.com/topic/151663-problem-with-for-loop/#findComment-796475 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.