Ir para conteúdo
Fórum Script Brasil

vfelipe364

Membros
  • Total de itens

    2
  • Registro em

  • Última visita

Posts postados por vfelipe364

  1. Não estou conseguindo atualizar os dados da minha tabela já tentei de tudo mais não vai se vôces puderem dar uma olhada e me falar no que errei agradeço

    Código Consulta:

    <html>
    <head>
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.0/css/materialize.min.css">
      <link rel="stylesheet" href="css/consulta.css"/>
      <link rel="stylesheet" href="css/style.css"/>
      <meta charset="UTF-8"/>
      <title>
          Resultado Da Pesquisa
      </title>
      <style>
        body{
            color: #000;
        }
      </style>
    </head>
    <body>
    <div class="conteudo">

      <?php
      //Criando tabela e cabeçalho de dados:
      echo "<table class = bordered striped centered highlight responsive-table>";
      echo "<thead>";
      echo "<tr>";
      echo "<th><font color='#F60'>Matricula</font></th>";
      echo "<th><font color='#F60'>Nome</font></th>";
      echo "<th><font color='#F60'>Email</font></th>";
      echo "<th><font color='#F60'>Data De Nascimento</font></th>";
      echo "<th><font color='#F60'>Telefone</font></th>";
      echo "<th><font color='#F60'>Curso</font></th>";
      echo "</tr>";
      echo "</thead>";

      //Conectando ao banco de dados
      $StringConexao = mysqli_connect('localhost','root','','BD_TrioFelipeCaioKristhyan')
      or die("Erro ao conectar ao BD_TrioFelipeCaioKristhyan");
      $sql = "SELECT * FROM TbCadastro";
      $resultado = mysqli_query($StringConexao, $sql)  or die("Erro ao encontrar a tabela TbCadastro");

      //Obtendo os dados por meio de um loop while
      while ($registro = mysqli_fetch_array($resultado)) {
          $matricula = $registro['matricula'];
          $nomeAluno = $registro['nome'];
          $email = $registro['email'];
          $nascimento = $registro['nascimento'];
          $telefone = $registro['telefone'];
          $curso = $registro['curso'];

          echo "<tr>";
          echo "<td>".$matricula."</td>";
          echo "<td>".$nomeAluno."</td>";
          echo "<td>".$email."</td>";
          echo "<td>".$nascimento."</td>";
          echo "<td>".$telefone."</td>";
          echo "<td>".$curso."</td>";
          echo "<td><a href=Deletar.php?matricula=".$matricula."><button class=btn_tabela> Deletar </button></a></td>";
          echo "<td><a href=Atualizar.php?matricula=".$matricula."><button class=btn_tabela> Atualizar </button></a></td>";
      }

      mysqli_close($StringConexao);

      echo "</table>";
      ?> 

      <br>

      <main>
        <center>
            <a href="Cadastrar.php" class="botao">Voltar</a>
        <center>
      </main>

    </div>
    </body>
    </html>

    Código Atualizar:

    <html>
    <head>
      <link rel="stylesheet" href="css/estilos.css"/>
      <link rel="stylesheet" href="css/style.css"/>
      <meta charset="UTF-8"/>
      <title>
          Trabalhando Com Conexão Ao Banco De Dados Felipe Vieira, Caio Leonardo e Kristhyan Carvalho
      </title>
      
      <?php
        $matricula = filter_input(INPUT_GET,"matricula");
        $nome = filter_input(INPUT_GET,"nome");
        $email = filter_input(INPUT_GET,"email");
        $nascimento = filter_input(INPUT_GET,"nascimento");
        $telefone = filter_input(INPUT_GET,"telefone");
        $curso = filter_input(INPUT_GET,"curso");
      ?>
      
      <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
      <script src="//cdnjs.cloudflare.com/ajax/libs/jquery.maskedinput/1.4.1/jquery.maskedinput.min.js"></script>
      
      <style>
        body{
            color: #000;
        }
      </style>
    </head>
    <body>
        <div class="conteudo">
            <h3><b> <span style="color: #F60;">Atualizar Cadastro</span> </b></h3>
            <form action = "Alterar.php">
                Matricula: <input type = "text" name = "Matri" size = "10" value = "<?php echo $matricula ?>"><br><br>

                Nome: <input type = "text" name = "NomeAluno" size = "45" value = "<?php echo $nome ?>"><br><br>

                Email: <input type = "email" name = "Email" size="45" value = "<?php echo $email ?>"><br><br>

                Data De Nascimento: <input type = "date" placeholder = "DD/MM/AAAA" name = "nascimento" value = "<?php echo $nascimento ?>"><br><br>

                Telefone: <input type = "text" maxlength = "15" id="telefone" name = "Telefone" value = "<?php echo $telefone ?>"><br><br>

                Curso: 
                <select name="Curso">
                    <option value = "DS">Desenvolvimento De Sistemas</option>
                    <option value = "ADM">Administração</option>
                    <option value = "NUTRI">Nutrição</option>
                    <option value = "RH">Recursos Humanos</option>
                    <option value = "QUÍM">Química</option>
                </select>
                
                <main>
                    <input type = "submit" name = "enviar" class="botao" value = "Enviar">
                    <a href="Consulta.php" class="botao">Voltar</a>
                </main>

                <!-- <input type = "submit" name = "enviar" value = "Enviar"> -->

                <script>
                    $(document).ready(function(){
                        $("#telefone").mask("(99) 99999-9999");
                    });
                </script>
            </form>
        </div>
    </body>
    </html>

    Código Alterar:

    <?php
    $matricula = filter_input(INPUT_GET, "matricula");
    $nome = filter_input(INPUT_GET, "nome");
    $email = filter_input(INPUT_GET, "email");
    $nascimento = filter_input(INPUT_GET, "nascimento");
    $telefone = filter_input(INPUT_GET, "telefone");
    $curso = filter_input(INPUT_GET, "curso");

    $StringConexao = mysqli_connect('localhost','root','','BD_TrioFelipeCaioKristhyan');

    if($StringConexao){
        $query = mysqli_query($StringConexao, "update TbCadastro set nome='$nome', email='$email', nascimento='$nascimento', telefone='$telefone', curso='$curso' where matricula='$matricula';");
        
        if($query){
            header("Location: Cadastrar.php");
        }else{
            die("Erro: ".mysqli_error($StringConexao));
        }
        
    }else{
        die("Erro: ".mysql_error($StringConexao));
    }
    ?>

  2. Pode ser meio idiota a pergunta mais estou postando aqui por não consegui fazer de jeito nenhum sou novo em sql e queria saber por que não consigo usar os inner join, left join, right join, full outer join full outer join, cross join.

    Código Que Eu Fiz:

    -- Criando Base De Dados
    Create Database Cafetaria;

    -- Chamando Base De Dados
    Use Cafetaria;

    -- Criando Tabela Comida
    Create Table Tbl_Comida(
    Id_Comida int identity,
    Comida varchar(30)
    );

    -- Criando Tabela Bebida
    Create Table Tbl_Bebida(
    Id_Bebida int identity,
    Bebida varchar(30)
    );

    -- Insert Refeições
    Insert Into Tbl_Comida Values ('Feijoada');
    Insert Into Tbl_Comida Values ('Strogonoff');
    Insert Into Tbl_Comida Values ('Frango Xadrez');
    Insert Into Tbl_Comida Values ('Camarão');

    -- Insert Bebidas
    Insert Into Tbl_Bebida Values ('Coca-Cola');
    Insert Into Tbl_Bebida Values ('Guaraná');
    Insert Into Tbl_Bebida Values ('Fanta Uva');
    Insert Into Tbl_Bebida Values ('Fanta Laranja');

    -- Chamando Tabela Comidas
    Select * From Tbl_Comida;

    -- Chamando Tabela Bebidas
    Select * From Tbl_Bebida;

    -- Chamando Tabela Pedidos
    Create Table Tbl_Pedido(
    Id_Pedido int identity,
    Id_Bebida int,
    Id_Comida int,

    constraint pkc_pedido primary key(Id_Pedido,Id_Bebida,Id_Comida)
    );

    -- Chamando Tabela Pedidos
    Select * From Tbl_Pedido;

    -- Join 1
    SELECT C.Comida, B.Bebida AS B, P.Id_Pedido AS P FROM AS C INNER JOIN Tbl_Bebida AS B ON C.Id_Comida = B.Id_Comida;

×
×
  • Criar Novo...