得到了以下函数,并且之前没有在任何地方声明 getteampoints 值。试图遵循其他重新声明错误问题,但没有一个有效。我怎样才能解决这个问题?
function getTeamPoints($team)
{
$query = mysql_query("SELECT * FROM Team_comp WHERE t_id='$team'");
$team_array = array();
while($a = mysql_fetch_array($query))
{
$team_array = array( 'home_won' => $a['home_win'],
'home_draw' => $a['home_tie'],
'home_lost' => $a['home_lost'],
'away_won' => $a['away_win'],
'away_draw' => $a['away_tie'],
'away_lost' => $a['away_lost'],
'home_games'=> $a['home_games'],
'away_games'=> $a['away_games']);
}
return $team_array;
}
function calculateTeamPoints($team, $type)
{
$teamPts = getTeamPoints($team);
if($type == 'home')
{
$homem = $teamPts['home_games'];
$homew = $teamPts['home_won'];
$percent = ($homew * 100) / $homem;
$remaining = $homem - $homew;
$per = ($remaining * 100) / $homem;
$percent += $per / 2;
}
elseif($type == 'away')
{
$homem = $teamPts['away_games'];
$homew = $teamPts['away_won'];
$percent = ($homew * 100) / $homem;
$remaining = $homem - $homew ;
$per = ($remaining * 100) / $homem;
$percent += $per / 2;
}
return $percent;
}
function getpercent($hometeamid, $awayteamid)
{
$hometeampts = calculateTeamPoints($hometeamid, 'home');
$awayteampts = calculateTeamPoints($awayteamid, 'away');
$homepercent = floor(($hometeampts - $awayteampts) + 50);
$awaypercent = 100-$homepercent;
}
//demo
getpercent($hometeamid, $awayteamid);
?>