Exclusão após inclusão
Boa tarde pessoal,
Estou com um probleminha que está me deixano de cabeça quente, o problema é o seguinte:
Possuo 2 tabelas com nomes diferentes porém com a mesma estrutura ( Tabela A e Tabela B),
quero que quando eu gravar os dados da tabela A na Tabela B eles sejam removidos da tabela "A" definitivamente
e permaneçam somente na tabela "B"
A Tabela "A" chama-se pre_cadastro_acompanhantes
A tabela "B" chamase acompanhantes
Abaixo coloquei o codigo da pagina aonde exibe os dados antes de inserir em na tabela "B"
----------------------------------------------------------------------------------------------
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO pre_cadastro_acompanhantes (nome, email, ddd, telefone, celular, sexo, nome_fantasia, ddd_contato, contato, idade, `local`, atendimento, somente, completo, usuario, senha, sobre) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['nome'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['ddd'], "text"),
GetSQLValueString($_POST['telefone'], "text"),
GetSQLValueString($_POST['celular'], "text"),
GetSQLValueString($_POST['sexo'], "text"),
GetSQLValueString($_POST['nome_fantasia'], "text"),
GetSQLValueString($_POST['ddd_contato'], "text"),
GetSQLValueString($_POST['contato'], "text"),
GetSQLValueString($_POST['idade'], "text"),
GetSQLValueString($_POST['local'], "text"),
GetSQLValueString($_POST['atendimento'], "text"),
GetSQLValueString($_POST['somente'], "text"),
GetSQLValueString($_POST['completo'], "text"),
GetSQLValueString($_POST['usuario'], "text"),
GetSQLValueString($_POST['senha'], "text"),
GetSQLValueString($_POST['sobre'], "text"));
mysql_select_db($database_nussbsb, $nussbsb);
$Result1 = mysql_query($insertSQL, $nussbsb) or die(mysql_error());
$insertGoTo = "cadastrado.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_nussbsb, $nussbsb);
$query_pre_cadastro_acompanhantes = "SELECT * FROM pre_cadastro_acompanhantes ORDER BY id DESC";
$pre_cadastro_acompanhantes = mysql_query($query_pre_cadastro_acompanhantes , $nussbsb) or die(mysql_error());
$row_pre_cadastro_acompanhantes = mysql_fetch_assoc($pre_cadastro_acompanhantes);
$totalRows_pre_cadastro_acompanhantes = mysql_num_rows($pre_cadastro_acompanhantes);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Titulo do meu site</title>
<style type="text/css">
<!--
body {
background-color: #333;
}
body,td,th {
color: #FFF;
font-size: 10px;
font-family: Verdana, Geneva, sans-serif;
font-weight: bold;
}
style2 {
font-size: 12px;
}
style2 {
font-weight: bold;
}
.style1 {
font-size: 11px;
color: #FFF;
}
style2 {
font-size: 10px;
}
.style2 {
color: #FFF;
}
.style3 {
font-weight: normal;
font-style: italic;
}
a:link {
color: #F60;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #FFF;
}
a:hover {
text-decoration: none;
color: #FFF;
}
a:active {
text-decoration: none;
color: #FFF;
}
-->
</style>
</head>
<body>
<table width="699" border="0" align="center">
<tr>
<td width="317" height="26" align="right" valign="middle" class="style1"> </td>
<td width="44" align="right" valign="middle" class="style1">BUSCA</td>
<td width="324" valign="top"><form id="form2" name="form2" method="post" action="">
<input type="text" name="textfield" id="textfield" />
<input type="submit" name="button" id="button" value="Buscar" />
</form></td>
</tr>
<tr>
<td height="26" align="right" valign="middle" class="style1"> </td>
<td align="right" valign="middle" class="style1"> </td>
<td valign="top" class="style3"><span class="style3">exemplo.(maria, joão)</td>
</tr>
</table>
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<table width="430" border="0" cellspacing="0" cellpadding="0">
<tr> </tr>
<tr> </tr>
<tr> </tr>
<tr> </tr>
<tr> </tr>
</table>
<table width="410" border="0" cellspacing="0" cellpadding="0">
<tr> </tr>
<tr> </tr>
<tr> </tr>
<tr> </tr>
</table>
<table width="200" border="0" cellspacing="0" cellpadding="0">
<tr> </tr>
<tr> </tr>
</table>
<p> </p>
<table border="0" align="center">
<tr bgcolor="">
<td width="230">Nome</td>
<td width="229">E-mail</td>
<td width="227">celular</td>
</tr>
<?php do { ?>
<tr bgcolor="#CCCCCC">
<td bgcolor="#0099CC"><a href="detalhe para inserir.php?recordID=<?php echo $row_pre_cadastro_acompanhantes['nome']; ?>"> <?php echo $row_pre_cadastro_acompanhantes['nome']; ?> </a></td>
<td bgcolor="#0099CC"><?php echo $row_pre_cadastro_acompanhantes['email']; ?> </td>
<td bgcolor="#0099CC"><?php echo $row_pre_cadastro_acompanhantes['celular']; ?> </td>
</tr>
<?php } while ($row_pre_cadastro_acompanhantes = mysql_fetch_assoc($pre_cadastro_acompanhantes)); ?>
</table>
<br />
<table width="412" border="0" cellspacing="0" cellpadding="0">
<tr> </tr>
</table>
<p>
<input type="hidden" name="MM_insert" value="form1" />
</p>
<p> </p>
</form>
</body>
</html>
<?php
mysql_free_result($pre_cadastro_acompanhantes);
?>Discussão (4)
Carregando comentários...