Return table value

Asked

Viewed 62 times

0

I would like to return the value of all my table to a change form or something, 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>';

  • The protocol field would be unique?

1 answer

0


You do not need to use a form on this page or the Submit button.

Use type button and script parent.location passing a single 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 '<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="button" class="btn btn-primary" onClick="parent.location=\'paginaDestino.php?id='.$registro["protocolo"].'\'">Ver mais</button>';
    }
    echo '</tr>';

}

echo '</table>';

Page destination - change form

 $protocolo= $_GET['id'];

 SELECT * FROM TABELA WHERE protocolo=$protocolo

with this you assemble a form to change the data related to this protocol

 <form action= ...... 
 <input .......
 ..............
 <button type="submit" .....
 </form>
  • Caraca leo, always saving me hahaha. Thanks, gave it right!!!

Browser other questions tagged

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