Forum Moderators: coopster
now i have another problem. I'll give your some informations to be more clear.
table : schedule
columns : gameno,hometeam,awayteam,homescore,awayscore,ot
Ok so what i want to do is create a scorebox that show the last game from the team. I want to put this on the same page as i put stats. The page with stats is teams.php?teams=ana and it shows me the stats from this team. I want to show the last game from the team i choose. If i write teams.php?team=ana i want to show the last game informations from anaheim. So the link would look like this teams.php?team=ana&boxscore=ana or whatever it is.. its just a supposition. I made a code but i miss some informations.. like if when i make my select i can only choose if the last game they played was home or away.. i cant have the real last game... so here's the code to help a little bit.. i dont know if i'm that clear but the only thing i want to is to show the last game played by the team.
This is the code to only show the scorebox of the last game played away :
<html><style type="text/css">
<!--
body,td,th {
font-family: verdana;
font-size: 12px;
}
-->
</style>
<body>
<table>
<?php
$db_host = 'localhost';
$db_user = 'root';
$db_pwd = '';
if (!mysql_connect($db_host, $db_user, $db_pwd))
die("Can't connect to database");
mysql_select_db("test");
if(!isset($_GET['awayteam'])) {
echo 'Category not specified';
die;
}
$result = mysql_query("SELECT hometeam,homescore,awayteam,awayscore from schedule where hometeam or awayteam= '" . mysql_real_escape_string($_GET['awayteam'])."' order by GameNo desc limit 1") or die(mysql_error());
while ($row = mysql_fetch_array($result))
{
echo "<tr><td align='left'>" . $row["hometeam"] . "</td><td align='center'>" . $row["homescore"] . "</td></tr>";
echo "<tr><td align='left'>" . $row["awayteam"] . "</td><td align='center'>" . $row["awayscore"] . "</td></tr>";
}
mysql_close();
?>
</table>
</body>
</html>
teams.php?team=ana
try replacing your query with these 2 lines
$team=mysql_real_escape_string($_GET['team']);
$result = mysql_query("SELECT hometeam,homescore,awayteam,awayscore from schedule where hometeam = '$team' or awayteam='$team' order by GameNo desc limit 1") or die(mysql_error());
And, oh change your IF condition to cate for the variable "team" not for awayteam
if(!isset($_GET['team']))
[edited by: Anyango at 4:54 am (utc) on Nov. 18, 2008]