Ir para conteúdo
Fórum Script Brasil
  • 0

Galeria de Fotos - alguém pode me ajudar?


CleberSilva

Pergunta

Tou fazendo este sisteminha de vendas para um cliente, só que acho que esta alguma coisa errada, alguém poderia me ajudar, para ver se esta certo dar uma olhada no codigo, fiz um curso de php, mas o professor era um matão agora estou me lascando sozinho, se alguém puder me dar uma ajuda agradeço.

Código lISTAR

<?

require ("conectdb.php");

$sql = "SELECT * FROM cadastro ORDER BY id DESC";


$limite = mysql_query("$sql");

while  ($sql = mysql_fetch_array ($limite) ) {

$arquivo = $_POST['arquivo'];
$arquivo1 = $_POST['arquivo1'];
$arquivo2 = $_POST['arquivo2'];
$arquivo3 = $_POST['arquivo3'];
$veiculo = $_POST['veiculo'];
$valor = $_POST['valor'];
$descricao = $_POST['descricao'];

?>
<style type="text/css">
<!--
.style1 {
    font-size: 18px;
    font-weight: bold;
}
body,td,th {
    font-family: Arial, Helvetica, sans-serif;
}
-->
</style>


<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <!--DWLayoutTable-->
  <tr>
    <th width="725" height="249" valign="top" scope="col"><table width="100%" border="0" align="center" cellpadding="5" cellspacing="0">
      <!--DWLayoutTable-->
      <tr>
        <th width="124" rowspan="2" scope="col"><a href="<? echo"../vendas/$arquivo";?>"><img src="<? echo"../vendas/$arquivo";?>" width='120' height="90" border="2" bordercolor='#FF6600'/></a></a></th>
          <th width="1" height="5"></th>
          <th width="132"></th>
          <th width="3"></th>
          <th width="131"></th>
          <th width="4"></th>
          <th width="128"></th>
          <th width="246"></th>
          <th width="116"></th>
      </tr>
      <tr>
        <th height="109"></th>
        <th colspan="6" align="left" valign="top" scope="col"><table width="100%" border="0" cellpadding="0" cellspacing="5">
          <!--DWLayoutTable-->
          <tr>
            <th width="508" align="left" scope="col">Veículo: <font color="#999999"><? echo"$veiculo";?></span></th>
              </tr>
          <tr>
            <th height="18" align="left" valign="top"><strong>Valor:<span class="style3"> <?echo"$valor";
 ?></span></strong></th>
              </tr>
          <tr>
            <th height="43" align="left" valign="top">Descrição:<span class="style3"><font color="#999999"><? echo"$descricao";?></span></th>
          </tr>
  
        </table></th>
          <th> </th>
      </tr>
      <tr>
        <th height="28" scope="col"> </th>
          <th> </th>
          <th> </th>
          <th> </th>
          <th> </th>
          <th> </th>
          <th> </th>
          <th> </th>
          <th> </th>
      </tr>
      <tr>
        <th height="104" scope="col"> </th>
          <th> </th>
          <th align="center" valign="top" scope="col"><a href="<? echo"../arquivos/$arquivo1";?>"><img src="<? echo"../vendas/$arquivo1";?>" width='120' height="90" border="2" bordercolor='#FF6600'/></a></th>
          <th> </th>
          <th valign="top"><a href="<? echo"../arquivos/$arquivo2";?>"><img src="<? echo"../arquivos/$arquivo2";?>" width='120' height="90" border="2" bordercolor='#FF6600'/></a></th>
          <th> </th>
          <th valign="top"><a href="<? echo"../arquivos/$arquivo3";?>"><img src="<? echo"../arquivos/$arquivo3";?>" width='120' height="90" border="2" bordercolor='#FF6600'/></a></th>
          <th> </th>
          <th> </th>
      </tr>
      <tr>
        <th height="13" scope="col"></th>
          <th></th>
          <th></th>
          <th></th>
          <th></th>
          <th></th>
          <th></th>
          <th></th>
          <th></th>
      </tr>
      
          
    </table></th>
  </tr>
</table>
<hr width="95%" color="#CCCCCC" />
<? } ?>
Codigo Upload
require("conectdb.php");
//se existir o arquivo
if(isset($_FILES["arquivo"])){

$arquivo = $_FILES["arquivo"];

$pasta_dir = "arquivos/";//diretorio dos arquivos
//se não existir a pasta ele cria uma
if(!file_exists($pasta_dir)){
mkdir($pasta_dir);
}

$arquivo_nome = $pasta_dir . $arquivo["name"];

// Faz o upload da imagem
move_uploaded_file($arquivo["tmp_name"], $arquivo_nome);

//conecta no banco
$arquivo = $_POST['arquivo'];
$arquivo1 = $_POST['arquivo1'];
$arquivo2 = $_POST['arquivo2'];
$arquivo3 = $_POST['arquivo3'];
$id = $_POST['id'];
$veiculo = $_POST['veiculo'];
$valor = $_POST['valor'];
$descricao = $_POST['descricao'];



$query = "INSERT INTO cadastro (arquivo, arquivo1, arquivo2, arquivo3, veiculo, valor, descricao) VALUES ('$arquivo_nome', $arquivo1_nome, $arquivo2_nome, $arquivo3_nome, $veiculo, $valor, $descricao)"; // inserção sql na tabela de cadastro
mysql_query($query) or die (mysql_error());
mysql_close();//fecha conexão

}

?>
<? echo "<center><font size='3'>Cadastrado com sucesso";
echo "<center><br>";
echo  "<img src='$arquivo_nome' width='250'><br>$nome";

 ?>
cÓDIGO Sql
CREATE TABLE `cadastro` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `veiculo` text NOT NULL,
  `valor` text NOT NULL,
  `descricao` text NOT NULL,
  `arquivo` text NOT NULL,
  `arquivo1` text NOT NULL,
  `arquivo2` text NOT NULL,
  `arquivo3` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMEN

Link para o comentário
Compartilhar em outros sites

3 respostass a esta questão

Posts Recomendados

  • 0

Você esqueceu de colocar o VALUES...

$query = "INSERT INTO cadastro VALUES (arquivo, arquivo1, arquivo2, arquivo3, veiculo, valor, descricao) VALUES ('$arquivo_nome', $arquivo1_nome, $arquivo2_nome, $arquivo3_nome, $veiculo, $valor, $descricao)"; // inserção sql na tabela de cadastro

Link para o comentário
Compartilhar em outros sites

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.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      652k
×
×
  • Criar Novo...