Mi problema es que quiero conseguir relacionar la id del contacto con el tag metido es decir
Yo creo el contacto "Juan Sanchez" le ingreso todos su datos (tlf, direccion etc...) le meto un tag "Arquitecto" y un tipo de tag "Persona". Y quiero que cuando le de a enviar el formulario en la tabla personas se me haya ingresado con la id X el nuevo contacto Juan Sanchez y en la tabla tags con la id X se me haya ingresado Arquitecto - Persona - Id Juan Sanchez.
Este es el codigo que tengo, está mal pq no tengo ni idea de como va el error es algo está equivocado en el sintax
Código PHP:
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO persoas (cod_prsa, cod_nme, cod_aplds, txt_nome_aclme, txt_aplds_aclme, txt_tlfno_trbllo, txt_tlfno_dmclo, txt_tlfno_mbl, txt_fx, cod_crro_1, cod_crro_2, cod_url, cod_ra, cod_nmr_ra, cod_nmr_pso, cod_endrzo_info_pls, cod_cp, cod_pblcn, cod_prvnca, cod_pis) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['cod_prsa'], "int"),
GetSQLValueString($_POST['cod_nme'], "text"),
GetSQLValueString($_POST['cod_aplds'], "text"),
GetSQLValueString($_POST['txt_nome_aclme'], "text"),
GetSQLValueString($_POST['txt_aplds_aclme'], "text"),
GetSQLValueString($_POST['txt_tlfno_trbllo'], "text"),
GetSQLValueString($_POST['txt_tlfno_dmclo'], "text"),
GetSQLValueString($_POST['txt_tlfno_mbl'], "text"),
GetSQLValueString($_POST['txt_fx'], "text"),
GetSQLValueString($_POST['cod_crro_1'], "text"),
GetSQLValueString($_POST['cod_crro_2'], "text"),
GetSQLValueString($_POST['cod_url'], "text"),
GetSQLValueString($_POST['cod_ra'], "text"),
GetSQLValueString($_POST['cod_nmr_ra'], "text"),
GetSQLValueString($_POST['cod_nmr_pso'], "text"),
GetSQLValueString($_POST['cod_endrzo_info_pls'], "text"),
GetSQLValueString($_POST['cod_cp'], "text"),
GetSQLValueString($_POST['cod_pblcn'], "text"),
GetSQLValueString($_POST['cod_prvnca'], "text"),
GetSQLValueString($_POST['cod_pis'], "text"));
mysql_select_db($database_bd_contactos, $bd_contactos);
$Result1 = mysql_query($insertSQL, $bd_contactos) or die(mysql_error());
}
if ($tags = isset($_POST["txt_tag"]) ? $_POST["txt_tag"] : false); {
$tags = explode(",", $tags);
$insertSQL2 = "insert into tags (txt_tag) values \n";
$contador = 0;
foreach($tags as $item){
if($contador) $insertSQL2 .= ", ";
$contador++;
$insertSQL2 .= "\n('$item')";
}
mysql_select_db($database_bd_contactos, $bd_contactos);
$Result12 = mysql_query($insertSQL2, $bd_contactos) or die(mysql_error());
}
if ($tags2 = isset($_POST["tpo_tag"]) ? $_POST["tpo_tag"] : false); {
$tags2 = explode(",", $tags2);
$insertSQL3 = "insert into tags (tpo_tag,cod_tpo_tag,cod_itm) values (\n,persoa,cod_prsa)";
$contador = 0;
foreach($tags2 as $item){
if($contador) $insertSQL3 .= ", ";
$contador++;
$insertSQL3 .= "\n('$item')";
}
mysql_select_db($database_bd_contactos, $bd_contactos);
$Result13 = mysql_query($insertSQL3, $bd_contactos) or die(mysql_error());
}