hi we have been working on this script and we are now stuck.
Code:
<?php
function build_league_table($admin) {
include("passwords.inc");
$connection = mysql_connect($host, $user,$password) or die ("Couldn't connect to server.");
$db = mysql_select_db($database, $connection) or die ("Couldn't select database.");
$sql = "SELECT teams.team_name, sum(dreamteam.points) 'total' ";
$sql .= "FROM teams, dreamteam ";
$sql .= "WHERE teams.team_admin = $admin ";
$sql .= "AND dreamteam.id ";
$sql .= "IN (teams.player_1, teams.player_2, teams.player_3, teams.player_4, teams.player_5, teams.player_6, teams.player_7, teams.player_8, teams.player_9, teams.player_10, teams.player_11) ";
$sql .= "GROUP BY teams.team_name ";
$sql .= "ORDER BY total DESC";
$result = mysql_query($sql) or die ("Error when building league table!");
echo "<font face='Verdana' size='-1'>";
if ($myrow = mysql_fetch_array($result)){
echo "<center>";
echo "<table border=1 bgcolor=#CFE0E8>\n";
echo "<tr bgcolor=#A5C5D2><td><center><b>Team Name</b></td><td><center><b>Points</b></td></tr>\n";
do {
/ printf("<tr><td><center>%s</td><td><center>%s</td></tr>\n", $myrow["TEAM_NAME"],$myrow["POINTS"]); /
echo "<tr><td><center>";
echo $myrow['team_name'];
echo "</td><td><center>";
echo $myrow['total'];
echo "</td></tr>\n";
} while ($myrow = mysql_fetch_array($result));
echo "</table></center>";
}
else {
echo "<center>";
echo "<h1><br><br><br><br><br>";
echo "Sorry, no records were found!";
}
}
/ End of function build_league_table() /
/ ----------------------------------------------------------------------------------------------- /
/ this function call will build the league table for TEAM_ADMIN = 1 & 2/
?>
<font size="6"><font color="#FFFFFF"><font face="Times New Roman, Times, serif">Ian's League Table</font></font></font>
<?php build_league_table(1); ?>
<font size="6"><font color="#FFFFFF"><font face="Times New Roman, Times, serif">Adam's League Table</font></font></font>
<?php build_league_table(2); ?>
please take a look at the script in action
http://www.dreamteam.greater-peterborough.com/
the problem i have is the team names
tom webster and stewart ward have got penalties on there points
what i need to be able to do is deduct points off there total
ie: tom webster has got 231 points i need to be able to -62 points
any idea how im able to do this,
or any idea how i can built the table seperatly with each team name. instead by team_admin
thanks for your help
jason