Tenho estes sistema funcionando, so queria que eu seleciona-se o nome e salva-se todos os dados da tabela 01 na tabela 02, mas ele somente salva o nome que selecionei...
<?php
include ('conexao.php');
$sql = "INSERT INTO SS_categories (
name,
parent,
products_count,
description,
picture,
products_count_admin
) VALUES (
'".mysql_real_escape_string($_POST['name'])."',
'0',
'2',
'1',
'0',
'2'
)";
$sql = mysql_query($sql)
or die ("Houve erro na gravação dos dados.:<br />".mysql_error());
?>
<h1>Cadastro efetuado com sucesso!</h1>
<h1>Aguardar ! Você será Redirecionado..</h1>
<?
sleep(5);
header("Location: etiquetas_cadastro.php");
?>
etiqueta_controle.php
<?php
include ('conexao.php');
$sql = "SELECT
*
FROM
SS_categories
ORDER BY
name";
$resultado = mysql_query($sql)
or die ("Não foi possível realizar a consulta.");
?>
<table align="center" border="2" bordercolor="#000000">
<tr>
<th bgcolor="#FFFFCC">Nome Produto:</th>
<th>Quantidade:</th>
<th bgcolor="#FFFFCC">Opções</th>
</tr>
<?php
while ($linha = mysql_fetch_array($resultado, MYSQL_ASSOC))
{
echo "<tr>";
echo "<td>{$linha['name']}</td>";
echo "<td>{$linha['description']}</td>";
echo "<td><a href='alterar.php?categoryID={$linha['categoryID']}'>Alterar</a> / ";
echo "<a href='excluir.php?categoryID={$linha['categoryID']}'>Excluir</a></td>";
echo "</tr>";
}
echo "</table>";
?>
OBS>.. Não Precisa aparecer os dados, somente quero que pegue os dados da tabela SS_categories2.sql , selecionando apenas o nome e salvando na tabela SS_categories.sql os dados do campo selecionado..
Pergunta
manogaucho
Oi tudo bem!
Tenho estes sistema funcionando, so queria que eu seleciona-se o nome e salva-se todos os dados da tabela 01 na tabela 02, mas ele somente salva o nome que selecionei...
Tabelas..
SS_categories.sql
SS_categories2.sql
Inserir dados na tabela SS_categories2.sql
Paginas....
conexao.php
<?php $conexao = mysql_connect("host","usuario","senha"); //Faz conexão com o mysql $db = mysql_select_db("banco_dados") ?>etiquetas_cadastro.php
<title>Cadastro Produtos</title> <table width="800" align="center"> <tr> <td align="center" valign="top"><strong><font size="4">Cadastrar Produtos na Lista dos Vendedores</font></strong></td> <td align="center" valign="top"> </td> </tr> <tr> <td width="100%" align="center" valign="top"><table width="500"> <tr> <td align="center" valign="top"> <form action="etiquetas_inserir.php" method="post"> <table width="500" align="center"> <tr> <td width="237"><div align="right">Nome Produto</div></td> <td width="351"><div align="left"> <select name="name" class="listmenu"> <option value="0" selected="selected">Selecione o Produto para cadastrar</option> <?php include ('conexao.php'); $sql = mysql_query("SELECT * FROM SS_categories2 ORDER BY name"); while ($linha = mysql_fetch_array($sql)) { echo '<option value="'.$linha['name'].'">'.$linha['name'].'</option>'; $categoryID = $_POST['name']; } ?> </select> </div></td> </tr> <tr align="center" valign="top"> <td colspan="2"><div align="right"></div> <p> </p> </td> </tr> <tr> <td colspan="2"><div align="center"> <input type="submit" value="Cadastrar"> </div></td> </tr> </table> </form> </td> </tr> </table></td> <td width="300" align="center" valign="top"> </td> </tr> </table> <table width="800" align="center"> <tr> <td align="center" valign="top"><p align="center"><strong></strong></p> <p><strong></strong></p> <table width="600" border="4" align="center" bordercolor="#FFCC00"> <tr> <td align="center" valign="top"> <? include("etiqueta_controle.php"); ?> </td> </tr> </table> <p> </td> </tr> </table>etiquetas_inserir.php
<?php include ('conexao.php'); $sql = "INSERT INTO SS_categories ( name, parent, products_count, description, picture, products_count_admin ) VALUES ( '".mysql_real_escape_string($_POST['name'])."', '0', '2', '1', '0', '2' )"; $sql = mysql_query($sql) or die ("Houve erro na gravação dos dados.:<br />".mysql_error()); ?> <h1>Cadastro efetuado com sucesso!</h1> <h1>Aguardar ! Você será Redirecionado..</h1> <? sleep(5); header("Location: etiquetas_cadastro.php"); ?>etiqueta_controle.php
<?php include ('conexao.php'); $sql = "SELECT * FROM SS_categories ORDER BY name"; $resultado = mysql_query($sql) or die ("Não foi possível realizar a consulta."); ?> <table align="center" border="2" bordercolor="#000000"> <tr> <th bgcolor="#FFFFCC">Nome Produto:</th> <th>Quantidade:</th> <th bgcolor="#FFFFCC">Opções</th> </tr> <?php while ($linha = mysql_fetch_array($resultado, MYSQL_ASSOC)) { echo "<tr>"; echo "<td>{$linha['name']}</td>"; echo "<td>{$linha['description']}</td>"; echo "<td><a href='alterar.php?categoryID={$linha['categoryID']}'>Alterar</a> / "; echo "<a href='excluir.php?categoryID={$linha['categoryID']}'>Excluir</a></td>"; echo "</tr>"; } echo "</table>"; ?>OBS>.. Não Precisa aparecer os dados, somente quero que pegue os dados da tabela SS_categories2.sql , selecionando apenas o nome e salvando na tabela SS_categories.sql os dados do campo selecionado..
Obrigadooo...
Link para o comentário
Compartilhar em outros sites
1 resposta a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.