Return table value



  • I would like to return the value of all my table to a change form or something of the kind, when clicked on my btn "see more", below the print of my screen:

    inserir a descrição da imagem aqui

    My code:

    echo '<form action="vermais.php" method="POST" accept-charset="utf-8" >';
    echo '<table class="table">';
    

    echo '<tr>';
    echo '<td>Protocolo</td>';
    echo '<td>Nome</td>';
    echo '<td>Setor</td>';
    echo '<td>E-mail</td>';
    echo '<td>Prioridade</td>';
    echo '<td>Data cadastrada</td>';
    echo '<td>Status</td>';

    echo '</tr>';

    while($registro = mysqli_fetch_assoc($sql)){

    $id=$registro['id_status'];
    $st = ("SELECT * FROM status WHERE id=$id");
    $sql2 = mysqli_query($conexao,$st);
    $row = mysqli_fetch_array($sql2);
    $s = $row['nome'];

    if("Em analise" == $s){
    $cor="blue";
    }else if("Aprovado" == $s){
    $cor="green";
    }else if("Pendente" == $s){
    $cor = "purple";
    }else{
    $cor = "red";
    }

    echo '<tr>';
    echo '<td>'.$registro["protocolo"].'</td>';
    echo '<td>'.$registro["nome"].'</td>';
    echo '<td>'.$registro["setor"].'</td>';
    echo '<td>'.$registro["email"].'</td>';
    echo '<td>'.$registro["prioridade"]. '</td>';
    echo '<td>'.$registro["data_cadastro"]. '</td>';
    echo '<td style="color:'.$cor.'">'.$row["nome"].'</td>';
    if($s !='Aprovado'){
    echo '<td> <button type="submit" class="btn btn-primary">Ver mais</button>';
    }
    echo '</tr>';

    }

    echo '</table>';

    echo '</form>';



  • You do not need to use a form on this page or submit button.

    Uses the type button and the script parent.location passing a unique parameter:

    <button type="button" class="btn btn-primary" onClick="parent.location=\'paginaDestino.php?id='.$registro["protocolo"].'\'">Ver mais</button>
    

    HTML

    echo '<table class="table">';
    

    echo '<tr>';
    echo '<td>Protocolo</td>';
    echo '<td>Nome</td>';
    echo '<td>Setor</td>';
    echo '<td>E-mail</td>';
    echo '<td>Prioridade</td>';
    echo '<td>Data cadastrada</td>';
    echo '<td>Status</td>';
    echo '</tr>';

    while($registro = mysqli_fetch_assoc($sql)){

    $id=$registro['id_status'];
    $st = ("SELECT * FROM status WHERE id=$id");
    $sql2 = mysqli_query($conexao,$st);
    $row = mysqli_fetch_array($sql2);
    $s = $row['nome'];
    
    if("Em analise" == $s){
        $cor="blue";
    }else if("Aprovado" == $s){
        $cor="green";
    }else if("Pendente" == $s){
        $cor = "purple";
    }else{
        $cor = "red";
    }
    
    echo '&lt;tr&gt;';
      echo '&lt;td&gt;'.$registro["protocolo"].'&lt;/td&gt;';
      echo '&lt;td&gt;'.$registro["nome"].'&lt;/td&gt;';
      echo '&lt;td&gt;'.$registro["setor"].'&lt;/td&gt;';
      echo '&lt;td&gt;'.$registro["email"].'&lt;/td&gt;';
      echo '&lt;td&gt;'.$registro["prioridade"]. '&lt;/td&gt;';
      echo '&lt;td&gt;'.$registro["data_cadastro"]. '&lt;/td&gt;';
      echo '&lt;td style="color:'.$cor.'"&gt;'.$row["nome"].'&lt;/td&gt;';
    if($s !='Aprovado'){
        echo '&lt;td&gt; &lt;button type="button" class="btn btn-primary" onClick="parent.location=\'paginaDestino.php?id='.$registro["protocolo"].'\'"&gt;Ver mais&lt;/button&gt;';
    }
    echo '&lt;/tr&gt;';
    

    }

    echo '</table>';

    landing page - change form

     $protocolo= $_GET['id'];

    SELECT * FROM TABELA WHERE protocolo=$protocolo

    with this you set up a form to change the data relating to this protocol

     <form action= ......
    <input .......
    ..............
    <button type="submit" .....
    </form>


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2