K I need to add this code
<?
$fp = fopen("$form_data1", "r");
$flatfile = fread($fp, filesize("$form_data1"));
fclose($fp);
for ($i = 1; $i <= 10; $i++) {
$flatfile = ereg_replace(" {3}", " ", $flatfile);
}
$csv = ereg_replace(" {2}", ", ", $flatfile);
$temp = str_replace(chr(10), chr(10).$_POST['team'], $csv);
$temp1 = str_replace(chr(10), chr(10).$_POST['game_id'], $temp);
$fp = fopen("$form_data1", "w+");
fwrite($fp, $temp1);
fclose($fp);
$result = mysql_db_query('mflblin_madden' ,"LOAD DATA LOCAL INFILE '$form_data' INTO TABLE stats FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' IGNORE 5 lines") or die(mysql_error());
?>
I need to add this to
//getting the teams's names
$team1=$matches[2][0];
$team2=$matches[3][0];
//querying their ids
echo $sql="SELECT
team_id, team_name
FROM
team
WHERE
team_name IN ('".$team1."', '".$team2."')";
$result=mysql_query($sql) or die(mysql_error());
while ($row=mysql_fetch_assoc($result))
$teams[]=$row;
//order them correct
if ($teams[0]['team_name']!=$matches[2][0])
list($teams[0], $teams[1])=array($teams[1], $teams[0]);
//insert game
print_r($teams);
echo $sql='INSERT INTO game
SET team1='.$teams[0]['team_id'].', team2='.$teams[1]['team_id'];
mysql_query($sql) or die(mysql_error());
//retrieve game_id
$game=mysql_insert_id();
//insert data
for ($i=1; $i<count($matches[2]); $i++)
$data[]=$matches[2][$i];
echo $sql='INSERT INTO result
(game_id, team_id, points, benchscoring, fieldgoals, fieldgoalp, threepointfg, threepointfgp, freethrows, freethrowp, rebounds, offrebounds, defrebounds, blocks, steals, assists, turnovers, fouls)
VALUES ('.$game.', '.$teams[0]['team_id'].', '.implode(', ', $data).')';
unset($data);
//test output
echo '<hr />'.$sql.'<p />';
mysql_query($sql) or die(mysql_error());
//the same for team2
for ($i=1; $i<count($matches[3]); $i++)
$data[]=$matches[3][$i];
echo $sql='INSERT INTO result
(game_id, team_id, points, benchscoring, fieldgoals, fieldgoalp, threepointfg, threepointfgp, freethrows, freethrowp, rebounds, offrebounds, defrebounds, blocks, steals, assists, turnovers, fouls)
VALUES ('.$game.', '.$teams[1]['team_id'].', '.implode(', ', $data).')';
//test output
echo $sql.'<hr />';
mysql_query($sql) or die(mysql_error());
?>
You see the line $temp1 = str_replace(chr(10), chr(10).$_POST['game_id'],
I want it to get the game_id from the second php script thou. All this is on one page. As of now there is no errors except it does not get the game_id from the second php code.