<?
$id = $_SESSION['id'];

$q = mysql_query("select producto_codigo from producto", $link);
$n = mysql_num_rows($q);
mysql_free_result($q);

mysql_query("delete from tup_codigo where insti_codigo=".$id, $link);/////////////
for ($i=1; $i<=$n; $i++){
	$cad = "i036".$i;
	if(!empty($_POST[$cad])){
		mysql_query("insert into servicio(insti_codigo, producto_codigo) values ($id ,$_POST[$cad])", $link);
	}
}

$q = mysql_query("select tup_codigo from tup", $link);
$n = mysql_num_rows($q);
mysql_free_result($q);

mysql_query("delete from aprop_tic where insti_codigo=".$id, $link);/////////////
for ($i=1; $i<=$n; $i++){
	$cad = "i037".$i;
	if(!empty($_POST[$cad])){
		mysql_query("insert into aprop_tic(insti_codigo, tup_codigo) values ($id ,$_POST[$cad])", $link);
	}
}
if(isset($aceptaro)){
		header("location:tup.htm");
	} else if(isset($aceptar)){
		header("location:vinculos.htm");
	}
?>