Formulario busca dados tabela01 e depois salva tabela02
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...
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...
Tabelas.. ( as duas tem campos iguais)
SS_categories.sql
CREATE TABLE IF NOT EXISTS SS_categories (categoryID int(11) NOT NULL,
name varchar(255) DEFAULT NULL,
parent int(11) DEFAULT NULL,
products_count int(11) DEFAULT NULL,
description text,
picture varchar(30) DEFAULT NULL,
products_count_admin int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;
SS_categories2.sql
CREATE TABLE IF NOT EXISTS SS_categories2 (categoryID int(11) NOT NULL,
name varchar(255) DEFAULT NULL,
parent int(11) DEFAULT NULL,
products_count int(11) DEFAULT NULL,
description text,
picture varchar(30) DEFAULT NULL,
products_count_admin int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2576 ;
Inserir alguns dados na tabela SS_categories2.sql
INSERT INTO SS_categories2 (categoryID, name, parent, products_count, description, picture, products_count_admin) VALUES
(5, 'LIXA DE UNHA
PACOTE UND', 0, 1, '5,25', '789123456', 1),
(6, 'SODA CAUSTICA KG', 0, 3, '1,09', '789654321', 3),
(7, 'MIREX 50G', 0, 1, '', '', 1),
(9, 'LIDER GEL
PERFUMADO/CARRO', 0, 1, '', '', 1),
(10, 'NAFTALINA', 0, 6, '', '', 6),
(11, 'NUGGETT PASTA PRETA', 0, 4, '', '', 4),
(12, 'NUGETT LIQ PRETO', 0, 4, '', '',
4),
(13, 'BRAVO LUSTRA MOVEIS', 0, 2, '', '', 2),
(14, 'BRILHO FACIL LUSTRA MOVEIS', 0, 2, '', '', 2),
(1042, 'AMACITEL 2 LTS', 0, 2, '0', '0', 5),
(17, 'ALCOOL
PARATI 1 LT', 0, 1, '', '', 1),
(18, 'ALCOOL PARATI 500ML', 0, 0, '', '', 0),
(19, 'ALCOOL COOPER ALCOOL 500ML', 0, 2, '', '', 2),
(2434, 'LUVA MUCAMBO', 0, 2,
'0', '0', 5),
(2384, 'JIMO LAVA CARRO', 0, 2, '0', '0', 5),
(22, 'REXON A 50ML MASC', 0, 5, '', '', 5),
(2482, 'CATCHUP C/189 DE 3GR', 0, 2, '0', '0', 5),
(24,
'REXONA SPRAY', 0, 1, '', '', 1),
(26, 'DOVE ROLLON', 0, 5, '', '', 5),
(27, 'TABU SPRAY', 0, 2, '', '', 2),
(28, 'AXE AEROSOL 90ML', 0, 4, '', '', 4),
(29, 'AXE
AEROSOL 150ML', 0, 5, '', '', 5),
(30, 'BOZZANO ESPUMA DE BARBA', 0, 5, '', '', 5),
(31, 'MONANGE DES ROLLON', 0, 4, '', '', 4),
(1043, 'NATU NOBILIS', 0, 2,
'0', '0', 5),
(33, 'OLEO PARA CABELO', 0, 3, '', '', 3),
(34, 'LISTERINE 250ML', 0, 4, '', '', 4),
(1044, 'CONHAQUE PRESIDENTE', 0, 2, '0', '0', 5),
(36,
'SORRISO 90G', 0, 8, '', '', 8),
(2368, 'CLOSE UP GEL 90GR', 0, 2, '0', '0', 5),
(38, 'SENSODYNE', 0, 2, '', '', 2),
(39, 'COLGATE BRANQUEADOR 90G', 0, 5, '',
2, '0', '0', 5),
(2560, 'PEROBA OLEO 100ML', 0, 2, '0', '0', 5),
(2561, 'YPE AMACIANTE 2 LT', 0, 2, '0', '0', 5),
(2562, 'COLGATE TOTAL12 CLEA MINT', 0, 2, '0',
'0', 5),
(2563, 'COLGATE TRIPLA MENTA SUAVE', 0, 2, '0', '0', 5),
(2564, 'COLGATE TRIPLA HORTELA', 0, 2, '0', '0', 5),
(2565, 'GILLETTE SENSOR 3 APARELHO', 0,
2, '0', '0', 5),
(2566, 'BOZZANO CREME BARBA SENSIVEL', 0, 2, '0', '0', 5),
(2567, 'PRESTOBARBA FEMENINO C/2', 0, 2, '0', '0', 5),
(2568, 'YPE SABAO C/5 200GR',
0, 2, '0', '0', 5),
(2569, 'DORIANA 500GR', 0, 2, '0', '0', 5),
(2570, 'DORIANA 500GR', 0, 2, '0', '0', 5),
(2571, 'DORIANA LIGHT 500GR', 0, 2, '0', '0', 5),
(2572, 'FUGINI MOLHO 350GR', 0, 2, '0', '0', 5),
(2573, 'FUGINI ESTRATO 340GR', 0, 2, '0', '0', 5),
(2574, 'FUGINI EXTRATO SACHE 240GR', 0, 2, '0', '0', 5),
(2575, 'ULTRAGRIP MOVEL C/2', 0, 2, '0', '0', 5);
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>";
?>
Um outro detalhe, pode tambem alterar o modo de pesquisa ( Busca) , estou usando um " listmenu " mas pode ser qualquer coisa para fazer a busca..... Obrigadooo
Discussão (1)
Carregando comentários...