1st let m thank those of you that have been helping me..
Ok I have set up a database to import NFL stats. Here is my problem. The data I get each will is compieled. It is not week by week, that is why I added the wk field to my database.
."(id, year, wk, cmp, att, yds, sack, td, int, long) "
Now I got it working perfect in mySQL. The only problem is they are compiled. What I need is for it to show each weeks stats. I left the code I use to insert the stats into the table, but that just imports the total stats.
I was thinking along the lines of
take new total stats for idX - IDX, YearX and all weeks. This would equal the stats for that given week.
I am asking could someone please help me out with this function. I have spent all Turkey Day here and although I feel like I accomplished alot, I have not been able to get the stats yet.
Thanks in Advance,
Matt
ID YEAR WK CMP ATT YARDS SACK TD INT LONG
1430 2005 1 14 28 163 3 1 0 35
1430 2005 2 36 59 361 3 2 2 46
1430 2005 3 53 88 524 4 4 3 46
1430 2005 4 68 120 682 6 5 6 46
1430 2005 5 88 148 929 11 6 6 46
function sql_insertPassingStats($roster, $table, $year, $team)
{
//debug2DArray($roster);
$count = count($table);
for ($i = 1; $i < $count; $i++)
{
$name = $table[$i][0] . " " . $table[$i][1];
list($pos, $ht, $wt) = getInfoFromRoster($roster, $name);
$name = addslashes($name);
$ht = addslashes($ht);
$id = sql_getPlayerID($name, $pos, $ht, $wt);
if ($id != false)
sql_insertPlayerPassingStats($id, $year, $table[$i]);
else
return errorPrint("Couldn't find player id for $pos $name");
}
return true;
}
function sql_insertPlayerPassingStats($id, $year, $table)
{
$db_table = MYSQL_PASSING;
if (!sql_emptyStats($db_table, $id, $year, $wk))
return errorPrint("The call to sql_emptyStats() in sql_insertPlayerPassingStats($id, $year, $table) failed");
$cmp = $table[2]; $att = $table[3]; $yds = $table[4]; $sack = $table[7]; $td = $table[8];
$int = $table[9]; $long = $table[10]; $wk = 5;
$query = "INSERT INTO $db_table "
."(`id`, `year`, wk, cmp, att, yds, sack, td, `int`, `long`) "
."VALUES ($id, $year, $wk, $cmp, $att, $yds, $sack, $td, $int, $long)";
$result = @mysql_query($query);
if ($result == false)
return errorPrint("The following query in sql_insertPlayerPassingStats($id, $year, $table); failed: <p><tt>$query</tt></p>");
return true;
}