Jump to content


Photo

Loop Breaks when I add some new code....


  • Please log in to reply
No replies to this topic

#1 jwer78

jwer78
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 06 July 2006 - 12:32 AM

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.
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");

Here is exactly what I added to the above script when it broke.
$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>";
}
In the echo I just added the variables. Again any help would be greatly appreciated.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users