我有一个页面,我希望看到该团队以绿色显示。我有以下SQL:
SELECT performance.id, matchid, playerid, team, debut, batpos, runs, ballsfaced, runs/ballsfaced*100 AS strikerate, fours, sixes, no, howout, fielder, bowler, ballsbowled, maidens, wickets, runsconceded, catches, stumpings, runouts, runsconceded/ballsbowled/6 AS economy, matches.round, matches.season, teams.id AS fteamid, a.id AS ateamid, teams.name AS hometeamname, a.name AS awayteamname, players.fname, players.surname
FROM performance
INNER JOIN matches ON performance.matchid=matches.id
INNER JOIN teams ON matches.hometeam = teams.id
INNER JOIN (SELECT teams.id, name FROM teams) AS a ON matches.awayteam = a.id
INNER JOIN players ON performance.playerid=players.id
以下php声明:
<?php
//if they play for this team display in green
if ($team['team'] == $team['fteamid']){
?>
<font color="green"><?php htmlout($team['hometeamname']); ?></font>
<?php } else {
?> <?php htmlout($team['hometeamname']); ?>
<?php } ?>
v
<?php
//if they play for this team display in green
if ($team['team'] == $team['ateamid']){
?>
<font color="green"><?php htmlout($team['awayteamname']); ?></font>
<?php } else {
?> <?php htmlout($team['awayteamname']); ?>
<?php } ?>
它适用于主队,但它不适用于客队,我无法弄清楚为什么,这对我来说似乎是正确的。有人可以指出我的错误吗?
答案 0 :(得分:0)
我发现了问题,这是表的错误,而不是代码
答案 1 :(得分:-1)
如果我看对了你就忘了在你的情况下设置一种颜色。
if ($team['team'] == $team['fteamid']){
$color="green";
} else {
$color="red";
}
$html= htmlout($team['awayteamname']);
echo "<span color='color:$color'>$html</span>";