jwer78 Posted July 6, 2006 Share Posted July 6, 2006 I am trying to add some new information to an existing web page. I added the loop but it breaks after the first result. Any help would be appreciated.[code]include("header.php");require_once("mainfile.php");$index=1;echo "<table align=center>";$id = Array();$team = Array();$name = Array();$position = Array();$type = Array();$length = Array();//Get max season$season_sql = "Select max(season) from team_schedule where league_id='1'";$season = mysql_query($season_sql);$season_num = mysql_fetch_array($season);$max_season = $season_num['max(season)'];//$db = @mysql_connect($dbhost,$dbuname,$dbpass);//@mysql_select_db($dbname,$db);$injury_query = "SELECT * FROM madcat_yearly_player_info WHERE injured='yes' and year='$max_season'";$i = 0;$injury_results = mysql_query($injury_query) or die(mysql_error());while($result = mysql_fetch_array($injury_results)) {$i++;$current_player_id = $result['id'];$current_team = $result['team'];$player_query = "SELECT * FROM madcat_players WHERE id='$current_player_id'";$player_results = mysql_query($player_query) or die(mysql_error());while($result2=mysql_fetch_array($player_results)){$player_name = $result2['name'];$player_pos = $result2['pos'];$id[$i] = $current_player_id;$team[$i] = strtolower($current_team);$name[$i] = $player_name;$position[$i] = $player_pos;$injury_query = "SELECT * FROM weekly_injuries WHERE player_name='$name[$i]'";$injury_results = mysql_query($injury_query) or die (mysql_error());while($result1=mysql_fetch_array($injury_results)){$injury_type = $result1['injury_type'];$injury_length = $result1['injury_length'];$type[$i] = $injury_type;$length[$i] = $injury_length;echo "<tr><td align=center class=injuryreport><img src=../../images/smalllogos/{$team[$i]}.gif></td><td align=center class=injuryreport>{$position[$i]}</td><td align-center class=injuryreport>{$name[$i]}</td><td align=center class=injuryreport>{$type[$i]}</td><td align=center class=injuryreport>{$length[$i]}</td></tr>";}}}echo "</table>";include("footer.php");[/code]Here is exactly what I added to the above script when it broke.[code]$injury_query = "SELECT * FROM weekly_injuries WHERE player_name='$name[$i]'";$injury_results = mysql_query($injury_query) or die (mysql_error());while($result1=mysql_fetch_array($injury_results)){$injury_type = $result1['injury_type'];$injury_length = $result1['injury_length'];$type[$i] = $injury_type;$length[$i] = $injury_length;echo "<tr><td align=center class=injuryreport><img src=../../images/smalllogos/{$team[$i]}.gif></td><td align=center class=injuryreport>{$position[$i]}</td><td align-center class=injuryreport>{$name[$i]}</td><td align=center class=injuryreport>{$type[$i]}</td><td align=center class=injuryreport>{$length[$i]}</td></tr>";}[/code]In the echo I just added the variables. Again any help would be greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/13801-loop-breaks-when-i-add-some-new-code/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.