PHP/MySQL - Inserting into 2 tables....... more complicated

Hi,
I am having difficulties with a form I am trying to insert the data into 2 different tables… I will explain what should happen. I have a form where a statistician can log into and add a player or edit his stats (the site is for a baseball club). I used to have all the info in one table, but that became too hard to manage. I have split the DB into 2 tables… one with player details, the other with his stats. The way I have made the 2 tables find the right stats is the ‘id’ field in one table and the ‘2005_id’ field in the 2nd table… my problem is having that 2nd id match the first one so the stats are displayed right. Does anyone know how I can insert all the player details into one table (the row will automatically insert the ‘id’ field), then find the ‘id’ field it created and then insert the rest of the information into the stats table (including the ‘id’ it created).

This code I can get to work inserting the data into two different tables, but the id for the 2nd table is ‘0’. I need it to match the ‘id’ of the 1st table. The ‘id’ is on auto-increment

$query = "INSERT INTO details ( club, ptype, fname, lname, number, age, d, m, y, ht, wt, bats, throws, position, hometown, school, gradyear, profile ) 
								
							values( '$club', '$ptype', '$fname', '$lname', '$number', '$age', '$d', '$m', '$y', '$ht', '$wt', '$bats', '$throws', '$position', '$hometown', '$school', '$gradyear', '$profile' )";
		mysql_query( $query )or die(mysql_error()); ;
		
			
		$query = "INSERT INTO 2005stats ( g, ab, rs, h, twob, threeb, hr, rbi, bb, sb, cs, so, gp, w, l, s, cg, sho, ha, ra, eragainst, walks, ip, k, avg, tb, obp, slg, obps, era, whip ) 
								
								values( '$g', '$ab', '$rs', '$h', '$twob', '$threeb', '$hr', '$rbi', '$bb', '$sb', '$cs', '$so', '$gp', '$w', '$l', '$s', '$cg', '$sho', '$ha', '$ra', '$eragainst', '$walks', '$ip', $k, '$avg', '$tb', '$obp', '$slg', '$obps', '$era', '$whip' )";
		
		mysql_query( $query )or die(mysql_error()); ;

This is what I have done to try and get the ‘id’ from the one table and insert it with the 2nd INSERT line. this is where I have the major problem.

$query = "INSERT INTO details ( id, club, ptype, fname, lname, number, age, d, m, y, ht, wt, bats, throws, position, hometown, school, gradyear, profile ) 
								
							values( '$id' '$club', '$ptype', '$fname', '$lname', '$number', '$age', '$d', '$m', '$y', '$ht', '$wt', '$bats', '$throws', '$position', '$hometown', '$school', '$gradyear', '$profile' )";
		mysql_query( $query )or die(mysql_error()); ;
		
		$2005_id = mysql_insert_id( $id );
			
		$query = "INSERT INTO 2005stats (2005_id, g, ab, rs, h, twob, threeb, hr, rbi, bb, sb, cs, so, gp, w, l, s, cg, sho, ha, ra, eragainst, walks, ip, k, avg, tb, obp, slg, obps, era, whip ) 
								
								values( '$2005_id', '$g', '$ab', '$rs', '$h', '$twob', '$threeb', '$hr', '$rbi', '$bb', '$sb', '$cs', '$so', '$gp', '$w', '$l', '$s', '$cg', '$sho', '$ha', '$ra', '$eragainst', '$walks', '$ip', $k, '$avg', '$tb', '$obp', '$slg', '$obps', '$era', '$whip' )";
		
		mysql_query( $query )or die(mysql_error()); ;

Any help would be appreciated… I think I spoke too much… thanks in advance.