php - Open another screen with the HTML table value

Asked

Viewed 37 times

-1

I need to click on the ID value of an html table and open another page (novapag.php) making echo of this value I clicked, I’m new and only know a little of php and HTML

Imagem dos ID que preciso clicar e fazer echo em outra página

<?php 
session_start();
 include_once("conectbusca.php"); 
 $pesquisaunid = $_SESSION['Unidade'];
 $pesquisa = $_SESSION['Senha']; 

 <?php 
 $sql = "SELECT ID, CPF,  Freada, Curva FROM tabela";
 $resultado = mysqli_query($strcon,$sql) or die("Erro ao retornar dados");
 $row = mysqli_num_rows($resultado);

 while ($registro = mysqli_fetch_array($resultado)) {
   $cpf = $registro['CPF'];
   $freada = $registro['Freada'];
   $curva = $registro['Curva'];
   $idautoinc = $registro['ID']; 

   echo "<tr>";
   echo "<td>".$cpf."</td>";
   echo "<td align='center'>".$freada."</td>";
   echo "<td align='center'>".$curva."</td>";
   echo "<td><a href='novapag.php'</a>".$idautoinc."</td>";
   echo "</tr>";
 } mysqli_close($strcon); 
 echo "</table>";?>

1 answer

0


I don’t really understand what you really want (ID line/tuple value or index). But following the logic of the code below you will be able to do what you want (I believe).

Follows Code:

<?php

header('Content-Type: text/html; charset=utf-8');

$idautoinc = 1;

echo "<form action='novapag.php' method='GET'>";
echo "<tr>";
echo "<td>
    <span>{$idautoinc}</span>
    <input style='opacity:0; width: 0px' type='text' name='id' value='{$idautoinc}'/>
</td>";
echo "</tr>";
echo "<input type='submit' value='Exibir'/>";
echo "</form>";

Page code declared in action form:

<?php

$idQueFoiClicado = htmlspecialchars($_GET['id']);
echo "Valor do ID: {$idQueFoiClicado}";

Obs.: I set the value in the variable to represent the data coming from the bank.

  • It worked out! Thank you very much!

Browser other questions tagged

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