Code error, buttons are doing the same form input functions

Asked

Viewed 19 times

0

I am making a code in php and I am having a problem, the buttons (which would be to delete and Abir a PDF file) are doing the same function as the form Input, I would like to know how I could solve this.

    <?php while($dados = mysqli_fetch_assoc($resultado_usuarios)) {?>
        <form action="editar.php" method="post"> 
           <div class="alunos">
             <input type="hidden" name="id" value='<?php echo $dados['id'] ?>'> <br>
              <h5> <b> Aluno: </b> <?php echo $dados["nome"] ?> <br>
                   <b> Turma: </b> <?php echo $dados["turma"] ?> &nbsp; 
                   <b> Número: </b> <?php echo $dados["numero"] ?> <br> <br>

                     <!-- editar dados -->
                     <input type="submit" value="Editar" class="editar">

                      <!-- Boletim -->
                      <a href="../_boletim/<?php echo $dados['caminho'] ?>.pdf" style="text-decoration: none;"> 
                         <button class="boletimBtn"> Boletim </button> 
                      </a>

                      <!-- apagar dados -->
                      <?php echo "<a href='excluir.php?id=". $dados['id'] ." data-confirm='#confirm-delete' '> <button class='apagar'> Apagar </button> </a>" ?>

                      <hr style='width: 100%'>

              </h5>
           </div>

        </form>

     <?php } ?>

1 answer

0


have tried this way?

<?php while($dados = mysqli_fetch_assoc($resultado_usuarios)) {?>
    <form action="editar.php" method="post"> 
       <div class="alunos">
         <input type="hidden" name="id" value='<?php echo $dados['id'] ?>'> <br>
          <h5> <b> Aluno: </b> <?php echo $dados["nome"] ?> <br>
               <b> Turma: </b> <?php echo $dados["turma"] ?> &nbsp; 
               <b> Número: </b> <?php echo $dados["numero"] ?> <br> <br>

                 <!-- editar dados -->
                 <input type="submit" value="Editar" class="editar">

                  <!-- Boletim -->
                  <a href="../_boletim/<?php echo $dados['caminho'] ?>.pdf" style="text-decoration: none;" class='btn btn-default'> 
                      Boletim
                  </a>

                  <!-- apagar dados -->
                  <?php echo "<a href='excluir.php?id=". $dados['id'] ."' data-confirm='#confirm-delete' class='apagar btn btn-danger'> Apagar </a>" ?>

                  <hr style='width: 100%'>

          </h5>
       </div>

    </form>

 <?php } ?>

In your code I saw two problems: 1) button inside a href ( totally wrong ) 2) On the second button you do not quote right after the ". $dados['id'] ." will only close before the first >

  • 1

    The code worked, thank you very much!

  • mark as solved rsss

Browser other questions tagged

You are not signed in. Login or sign up in order to post.