Baixe o app para aproveitar ainda mais
Esta é uma pré-visualização de arquivo. Entre para ver o arquivo original
<?php session_start(); if (!isset($_SESSION['logado'])){ header("Location: login.php"); } include("conexao.php"); if (($_SESSION["t_usuario"] == "2")){ header("Location:logout.php"); } $id_buscado = $_GET["id"]; $sql = "SELECT nomeproduto, tipoproduto, img1, img2, img3, idade, genero, personagem, marca, preco, descricao, quantidade FROM produto where idproduto='$id_buscado'"; $result =$GLOBALS['conn']->query($sql); while ( $row1 = $result->fetch_array(MYSQLI_ASSOC) ){ $nome = $row1["nomeproduto"]; $tipo = $row1["tipoproduto"]; $img1 = $row1["img1"]; $img2 = $row1["img2"]; $img3 = $row1["img3"]; $idade = $row1["idade"]; $genero = $row1["genero"]; $personagem = $row1["personagem"]; $marca = $row1["marca"]; $precoproduto = $row1["preco"]; $descricao = $row1["descricao"]; $qtdproduto = $row1["quantidade"]; } ?> <!DOCTYPE html> <html lang="pt-br"> <head> <title>Edição do Produto</title> <meta content="html/text" charset="utf-8"> <?php include("head.php");?> </head> <body> <?php include("topo.php"); ?> <?php $sql = "select tipoproduto, tipoproddesc from tipoproduto"; $result = $GLOBALS['conn']->query($sql); $tipop = ""; while ($row2 = $result->fetch_array(MYSQLI_ASSOC)) { if ($row2["tipoproduto"] == $tipop){ $tipop .= "<option value=\" ".$row2["tipoproduto"]. "\" selected>".$row2["tipoproddesc"]. "</option> "; }else{ $tipop .= "<option value=\" ".$row2["tipoproduto"]. "\" >".$row2["tipoproddesc"]. "</option> "; } } ?> <?php $sql = "select idade, faixaidade from idade"; $result = $GLOBALS['conn']->query($sql); $idade = ""; while ($row3 = $result->fetch_array(MYSQLI_ASSOC)) { if ($row3["idade"] ==$idade){ $idade .= "<option value=\" ".$row3["idade"]. "\" selected>".$row3["faixaidade"]. "</option> "; }else{ $idade .= "<option value=\" ".$row3["idade"]. "\">".$row3["faixaidade"]. "</option> "; } } ?> <?php $sql = "select genero, tipogenero from genero"; $result = $GLOBALS['conn']->query($sql); $genero = ""; while ($row4 = $result->fetch_array(MYSQLI_ASSOC)) { if ($row4["genero"] ==$genero){ $genero .= "<option value=\" ".$row4["genero"]. "\" selected>".$row4["tipogenero"]. "</option> "; }else{ $genero .= "<option value=\" ".$row4["genero"]. "\">".$row4["tipogenero"]. "</option> "; } } ?> <?php $sql = "select personagem, tipoperson from personagem"; $result = $GLOBALS['conn']->query($sql); $personagem = ""; while ($row5 = $result->fetch_array(MYSQLI_ASSOC)) { if ($row5["personagem"] ==$personagem){ $personagem .= "<option value=\" ".$row5["personagem"]. "\" selected>".$row5["tipoperson"]. "</option> "; }else{ $personagem .= "<option value=\" ".$row5["personagem"]. "\">".$row5["tipoperson"]. "</option> "; } } ?> <?php $sql = "select marca, tipomarca from marca"; $result = $GLOBALS['conn']->query($sql); $marca = ""; while ($row6 = $result->fetch_array(MYSQLI_ASSOC)) { if ($row6["marca"] ==$marca){ $marca.= "<option value=\" ".$row6["marca"]. "\" selected>".$row6["tipomarca"]. "</option> "; }else{ $marca.= "<option value=\" ".$row6["marca"]. "\">".$row6["tipomarca"]. "</option> "; } } ?> <?php include("menu_lateral.php");?> <h3>Edição de Produto</h3> <form id="form" name="form" action="update_produto.php" method="post" enctype="multipart/form-data"> <fieldset> <table cellspacing=""> <input type="hidden" value="<?php echo $id_buscado; ?>" name="id"> <tr> <td> <label for="nomeproduto">Nome do produto</label> </td> <tr> <td align="left"> <input type="text" name="nomeproduto" value="<?php echo $nome;?>" class="form-control"> </td> </tr> </tr> <tr> <td> <label for="precoproduto">Preço do produto</label> </td> </tr> <tr> <td align="left"> <input type="number" name="precoproduto" value="<?php echo $precoproduto;?>" class="form-control" required="required"> </td> </tr> <tr> <td> <label for="imagem">Imagem 1 do produto</label> </td> <td><input type="file" id="foto1" name="foto1" value="" class="btn btn-default" /></td> <td><img src="uploads/<?php echo $img1; ?>" height='80' width='80'></td> </tr> <tr> <td> <label for="imagem">Imagem 2 do produto</label> </td> <td><input type="file" id="foto2" name="foto2" value="" class="btn btn-default"/></td> <td><img src="uploads/<?php echo $img2; ?>" height='80' width='80'></td> </tr> <tr> <td> <label for="imagem">Imagem 3 do produto</label> </td> <td><input type="file" id="foto3" name="foto3" value="" class="btn btn-default"/></td> <td><img src="uploads/<?php echo $img3; ?>" height='80' width='80'></td> </tr> <tr> <td> <label for="tipoproduto">Tipo de produto</label> </td> </tr> <td align="left"> <select class="form-control" name="tipoproduto"> <option value="0">Selecione o tipo</option> <?php echo $tipop;?> </select> </td> </tr> <tr> <td> <label for="idadeproduto">Faixa etária do produto</label> </td> </tr> <td align="left"> <select class="form-control" name="idadeproduto" required> <option value="0">Selecione a faixa etária</option> <?php echo $idade;?> </select> </td> </tr> <tr> <td> <label for="generoproduto">Gênero alvo do produto</label> </td> </tr> <td align="left"> <select class="form-control" name="generoproduto" required> <option value="0">Selecione o gênero</option> <?php echo $genero;?> </select> </td> </tr> <tr> <td> <label for="personproduto">Personagem ligado ao produto</label> </td> </tr> <td align="left"> <select class="form-control" name="personproduto" required> <option value="0">Selecione o personagem</option> <?php echo $personagem;?> </select> </td> </tr> <tr> <td> <label for="marcaproduto">Marca do produto</label> </td> </tr> <td align="left"> <select class="form-control" name="marcaproduto" required> <option value="0">Selecione a marca</option> <?php echo $marca;?> </select> </td> </tr> <tr> <td> <label for="qtdproduto">Estoque atual</label> </td> <td> <label for="adicionarproduto">Adicionar ao estoque</label> </tr> <tr> <td align="left"> <input type="number" name="qtdproduto" value="<?php echo $qtdproduto;?>" class="form-control" required="required" readonly> </td> <td> <input type="number" name="adicionarproduto" value="" class="form-control" > </tr> <tr> <td> <label for="descricao">Descrição do Produto</label> </td> </tr> <tr> <td align="left"> <textarea name="descricao" class="form-control" id="descricao" maxlength="1000" value="<?php echo $descricao;?>"></textarea> <p id="contador"></p> <script type="text/javascript"> $('#descricao').keyup(function () { var left = 1000 - $(this).val().length; if (left < 0) { left = 0; } $('#contador').text('Caracteres restantes: ' + left); }); </script> </td> </tr> </table> <input type="submit" class="btn btn-default" name="cadastrar" value="Enviar" ></input> <input type="reset" class="btn btn-default" value="Limpar"> </fieldset> <?php include("rodape.php");?> <?php include("scripts.php");?> </body> </html>
Compartilhar