How can I separate this page into years I would like there to be a link above
For instance
2005 2006 2007 (only years that are in the tables though)
Then below I want to retrieve each weeks stats from that year. (by the way if you are looking a the webpage, I know week 1 stats are the same for both years, that’s because I used the same stats just changed the year for testing)
This page
http://www.str8playaz.com/Backup/player.php?id=551&skin=default
Is good I want the years on top of each other.
This Page
http://www.str8playaz.com/Backup/player.php?id=551&sub=gbg&skin=default
is not good, I do not want the years on top of each other just the weeks and want it separated into years.
Ok now I will paste sections of code I think the problem is in (just guessing)
//this code loads the statistics tables for the player
if ($_GET["sub"] == "gbg") {
for ($s = 0; $s < count($tables); $s++)
{
$stats = sql_getgbgStats($player["id"], $tables[$s], $lables[$s]);
if ($stats != "")
{
echo "<tr>";
echo "<td>";
echo make_table($stats, "darkback", count($stats[2]));
echo "</td>";
echo "</tr>";
}
}
}
function sql_getGbgStats($id, $db_table, $title)
{
$headers = getHeaders();
$pinfo = MYSQL_YRLY_PLAY_INFO;
$queryStart = "SELECT $db_table.year, $pinfo.team, ";
$queryMiddle = getGbgStatQuery($db_table);
$queryEnd = " FROM $pinfo, $db_table "
."WHERE "
." ($pinfo.id = $id) AND ($db_table.id = $pinfo.id) AND ($db_table.year = $pinfo.year) "
."ORDER BY `year` ASC";
$query = $queryStart . $queryMiddle . $queryEnd;
$result = mysql_query($query);
if (@mysql_num_rows($result) == 0)
return ""; //not an error; the player just doesn't have this kind of stats
else
{
$player = array();
$player[0] = array();
$player[1] = array();
while (true)
{
$temp = @mysql_fetch_array($result, MYSQL_NUM);
if ($temp == false)
break;
if ($db_table == MYSQL_GBGPASSING)
{
$rating = count($temp)-1;
$temp[$rating] = number_format($temp[$rating], 1);
}
$player[] = $temp;
}
$player[0][0] = "$title";
$player[1] = $headers[$db_table];
$player[] = getTotalGbgStats($db_table, $id);
array_unshift($player[count($player)-1], " ", "TOTALS");
}
return $player;
}
function getTotalGbgStats($db, $id)
{
$queryStart = "SELECT ";
$queryMiddle = getTotalGbgStatQuery($db);
$queryEnd = " FROM $db WHERE (id = $id) GROUP BY id";
$query = $queryStart . $queryMiddle . $queryEnd;
$result = mysql_query($query) or die(MySQL_Error());
if ($result == false)
return errorPrint("The following query in sql_getTotalGbgStats($db, $id); failed: <p><tt>$query</tt></p>");
if (@mysql_num_rows($result) == 0)
return ""; //not an error; the player just doesn't have this kind of stats
$temp = @mysql_fetch_array($result, MYSQL_NUM);
if ($db == MYSQL_GBGPASSING)
$temp[count($temp)-1] = number_format($temp[count($temp)-1], 1);
return $temp;
}
One last piece of code
function getGbgStatQuery($table, $select = "")
{
if ($table == MYSQL_GBGPASSING)
{
$wk = $cats["wk"] = "$table.wk";
$cmp = $cats["cmp"] = "$table.cmp";
$att = $cats["att"] = "$table.att";
$cmp_pct = $cats["cmp_pct"] = "(IFNULL(($table.cmp / $table.att), 0.0)*100) AS cmp_pct";
$yds = $cats["yds"] = "$table.yds";
$ypa = $cats["ypa"] = "IFNULL(($table.yds / $table.att), 0.0) AS ypa";
$long = $cats["long"] = "$table.long";
$td = $cats["td"] = "$table.td";
$int = $cats["int"] = "$table.int";
$sack = $cats["sack"] = "$table.sack";
//as hideous as this query is, it makes life in the rest of MADCAT absolutely heavenly
$per = 2.375;
$ratTDPass1 = "((IFNULL($table.td / $table.att, 0.0)*100)*.2)";
$ratTDPass2 = "IF($ratTDPass1 > $per, $per, $ratTDPass1)";
$ratTDPass = "IF($ratTDPass2 < 0, 0, $ratTDPass2)";
$ratINTPass1 = "($per-((IFNULL($table.int / $table.att, 0.0)*100)*.25))";
$ratINTPass = "IF($ratINTPass1 < 0, 0, $ratINTPass1)";
$ratCMPPct1 = "(((IFNULL($table.cmp / $table.att, 0.0)*100)-30)*.05)";
$ratCMPPct2 = "IF($ratCMPPct1 > $per, $per, $ratCMPPct1)";
$ratCMPPct = "IF($ratCMPPct2 < 0, 0, $ratCMPPct2)";
$ratYPA1 = "((IFNULL($table.yds / $table.att, 0.0)-3)*.25)";
$ratYPA2 = "IF($ratYPA1 > $per, $per, $ratYPA1)";
$ratYPA = "IF($ratYPA2 < 0, 0, $ratYPA2)";
$_rating = "$ratCMPPct + $ratYPA + $ratTDPass + $ratINTPass";
$rating2 = "($_rating) / 6";
$rating = "$rating2 * 100 as rating";
$cats["rating"] = $rating;
if ($select != "")
return $cats[$select];
$query = "$wk, $cmp, $att, $cmp_pct, $yds, $ypa, $long, $td, $int, $sack, $rating";
return $query;
}