<?PHP
function adjustraces(){
	$query = 'select * from race_info where race_id < 12';
	$result = mysql_query2($query);

	while ($line = mysql_fetch_array($result, MYSQL_BOTH)){
		$cp = $line[name] . '_initialcp';
		$cpQuery = "update race_info set initial_cp=$_POST[$cp] where name='$line[name]'";
		mysql_query2($cpQuery) or die ("Bad Query");

		$start_x = $line[name] . '_start_x';
		$start_y = $line[name] . '_start_y';
		$start_z = $line[name] . '_start_z';

		$positionQuery = "update race_info set start_x=$_POST[$start_x],
	                                           start_y=$_POST[$start_y],
	                                           start_z=$_POST[$start_z] 
	                                       where  name='$line[name]'";
		mysql_query2($positionQuery);

		$sector = $line[name] . '_sectorName';
		$sectorIDQuery = "select id from sectors where name='$_POST[$sector]'";
		$sectorIDResult = mysql_query2($sectorIDQuery);
		$IDline = mysql_fetch_row($sectorIDResult);
		$sectorQuery = "update race_info set start_sector_id=$IDline[0] where name='$line[name]'";
		mysql_query2($sectorQuery);

		Header('Location: index.php?page=maincharcreate');
	}
}

?>