<html>
<head>
<title>Descrição de Veiculos</title>
<style>
.branco{background:#FFFFFF}
.cinza{background:#CCCCCC}
a:hover{color:#336699; text-decoration:underline}
a{color:#336699; text-decoration:none}
td{border-left:1px solid white}
th{border:1px solid blue}
</style>
</head>
<body>
<form name="form1" method="POST" action="cadastra_inicial.php">
<table cellpadding=3 cellspacing=0>
<tr>
<td></td><th>Imagem</th><th>Modelo</th><th>Fabricante</th><th>Placa</th><th>Combustivel</th><th>Cor</th><th>Ano</th>
</tr>
<?php
include "abreconexao.inc";
$sql = "select v.nm_imagem_veiculo,v.nm_modelo_veiculo,f.nm_fabricante,v.cd_placa_veiculo,v.nm_combustivel,v.nm_cor_veiculo,
v.aa_ano_veiculo,v.flag from veiculo v, fabricante f where v.cd_fabricante=f.cd_fabricante";
$rs = mysql_query($sql, $conexao);
$qtde=mysql_num_rows($rs);
$aux=0;
while($aux<$qtde){
$campo = mysql_fetch_array($rs);
if($aux%2){$classe="branco";}else{$classe="cinza";}
if($campo[7]=="1"){$flag="checked";}else{$flag=" ";}
echo "<tr class='".$classe."'><td><input type='checkbox' name='selecao".$aux."' value='".$campo[3]."' ".$flag."></td>
<td><img src='imagens/".$campo[0]."' width=76' height='57'></td><td>".$campo[1]."</td><td>".$campo[2]."</td>
<td>".$campo[3]."</td><td>".$campo[4]."</td><td>".$campo[5]."</td><td>".$campo[6]."</td></tr>\n";
$aux=$aux+1;
}
?>
<input type="hidden" name='qtde' value='<?php echo $qtde;?>'>
<input type="submit" value="Enviar!">
</form>
</table>
</body>
</html>
Está a a pagina q recebe:
[code=auto:0]<?php
// pega os valores
$qtde=$_POST["qtde"];
$aux=0;
while($aux<$qtde){
$str="selecao".$aux;
$selecao[$aux]=$_POST[$str];
echo (isset($selecao))? "Foi setado" : "Não Setado";
$aux=$aux+1;
}
// abre a conexao
include "abreconexao.inc";
$sql1="delete from inicial";
$rs2 = mysql_query($sql1, $conexao);
$sqlzera="update veiculo set flag='0'";
$rszera=mysql_query($sqlzera,$conexao);
// Gera inclusão
$aux=0;
while($aux<$qtde){
if($selecao[$aux]){
$sqlINS = "INSERT into inicial values ('$selecao[$aux]')";
// carrega os registros
$rs = mysql_query($sqlINS, $conexao) or die ("Não foi possivel executar a instrução insert!");
$sql="update veiculo set flag='1' where cd_veiculo='$selecao[$aux]'";
$rs1= mysql_query($sql,$conexao);
}
$aux=$aux+1;
}
echo "<h1 align='center'>Cadastrado!!!</h1>";
?>
[QUOTE]



Postagens
Não informado

