I am working with a piece of code at present, which by design is intended to produce results of football matches on a page. The page will display the results of one team, for one specified season.
Here is an example of what is currently being displayed:
http://www.tainthistle.co.uk/welfare/club_matches.php?clubid=1&seasonid=1
Here is the code for the above:
<?php
include('authenticate.php');
$connection = mysql_connect("$host","$user","$password")
or die(mysql_error());
mysql_select_db("$txt_db_name",$connection)
or die(mysql_error());
$team2search = $_GET['clubid'];
$team2check = (int) $team2search;
$season2search = $_GET['seasonid'];
$season2check = (int) $season2search;
{
$print_date = '%d %M %Y';
}
{
$get_matches = mysql_query("
SELECT H.TeamName AS homeside,
A.TeamName AS awayside,
M.MatchHomeGoals AS homegoals,
M.MatchAwayGoals AS awaygoals,
M.MatchID AS match_id,
DATE_FORMAT(M.MatchDate, '$print_date') AS match_date
FROM tdfp_matches M, tdfp_teams H, tdfp_teams A
WHERE H.TeamID = M.MatchHomeID AND
A.TeamID = M.MatchAwayID AND
(H.TeamID = $team2search OR A.TeamID = $team2search) AND
M.MatchSeasonID = $season2search
ORDER BY M.MatchDate DESC",$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"<b>$data[match_date]</b><br>";
}
if($data['match_date'] != "$temp" && $i > 0)
{
echo"<b>$data[match_date]</b><br>";
}
echo"
$data[homeside] $data[homegoals]-$data[awaygoals] $data[awayside]<br><br>
";
echo"";
$temp = "$data[match_date]";
$i++;
}
}
mysql_free_result($get_matches);
?>
What I now want to do is incorporate a couple of other tables, to also display the names of the players who scored the goals, under each result.
I've hit a mental block and can't figure out the logical next step.
I have created the following tables:
tdfp_players (PlayerID, PlayerName)
tdfp_goals (GoalID, GoalMatchID, GoalTeamID, GoalScorerID)
GoalScorerID = PlayerID here
What I hope to do is to include this information in the code I have above, but need some help building it in. Any ideas would be greatly appreciated.