I'm adapting some code I use for a football website, which displays recent results of matches. It displays recent matches fine, but for some reason, if the home team has a score of 0, it wont display that game result.
I have tried a few different things with this code but can't work out what I'm doing wrong. Anything stand out to anyone?
<html>
<head><title>Fixtures & Results</title></head>
<body>
<?php
include('league/admin/user.php');
$connection = mysql_connect("$host","$user","$password")
or die(mysql_error());
mysql_select_db("$txt_db_name",$connection)
or die(mysql_error());
//
//Season id
//
$season_id = 1;
{
$print_date = '%M %D, %Y';
}
{
$get_matches = mysql_query("
SELECT O.OpponentShort AS hometeam,
OP.OpponentShort AS awayteam,
LM.LeagueMatchHomeGoals AS goals_home,
LM.LeagueMatchAwayGoals AS goals_away,
LM.LeagueMatchID AS id,
DATE_FORMAT(LM.LeagueMatchDate, '$print_date') AS date
FROM rwl_leaguematches LM, rwl_opponents O, rwl_opponents OP
WHERE O.OpponentID = LM.LeagueMatchHomeID AND
OP.OpponentID = LM.LeagueMatchAwayID AND
LM.LeagueMatchHomeGoals AND
LM.LeagueMatchSeasonID LIKE '$season_id'
ORDER BY LM.LeagueMatchDate DESC
LIMIT 0, 8",$connection)
or die(mysql_error());
}
if(mysql_num_rows($get_matches) < 1)
{
echo "<b>No matches yet.</b>";
}
else
{
$i = 0;
$temp = '';
while($data = mysql_fetch_array($get_matches))
{
if($i == 0)
{
echo"
<table width=100%>
<tr>
<td align=\"center\" colspan=\"2\">
<b>$data[date]</b>
</td>
</tr>
";
}
if($data['date'] != "$temp" && $i > 0)
{
echo"
<tr>
<td align=\"center\" colspan=\"2\">
<br>
<b>$data[date]</b>
</td>
</tr>
";
}
echo "
<tr>
<td align=\"center\" valign=\"top\" width=\"100%\">
$data[hometeam] $data[goals_home]-$data[goals_away] $data[awayteam]
</td>";
if(!is_null($data['goals_home']))
echo"";
else
echo' ';
echo"
</tr>";
$temp = "$data[date]";
$i++;
}
}
mysql_free_result($get_matches);
?>
</table>
</body>
</html>