I need to take the patient id from the table to the next page, along with the user, by clicking the button

0
<?php
$conexao = new mysqli("localhost","root","","hospital");

if($conexao->connect_errno){
    echo"Failed to connect to MySQL: (" . $conexao->connect_errno   .") " . $conexao->connect_error;
}

$res = $conexao->query("SELECT nome, idade, cpf from paciente, ficha_atendimento, questionario WHERE paciente.id = ficha_atendimento.id_paciente AND paciente.id = questionario.id_paciente");


echo "<table class='table table-striped'>";
echo "<tr>
        <td>Nome</td>
        <td>Idade</td>
        <td>CPF</td>
        </tr>";

while($row = mysqli_fetch_assoc($res)) {

    echo "<tr class='info'>
    <td>". $row['nome']."</td>
    <td>". $row['idade']."</td>
    <td>". $row['cpf']."</td>
    <td><a href='sala_questionario.php'><button class='btn btn-info'>Redirecionar</button></a></td>
    </tr>";
}

echo "</table>";


?>

The 'patient' table has the fields name age and cpf, and all these are being printed on the table, next to a button (in the code above) that redirects the patient to a page that he will answer a questionnaire. However, I need to take the id of this patient to this next page when he is redirected so that when he answers the questionnaire the program sends the data to the 'questionnaire' table that has a foreign key called patient id that corresponds to the patient id of the patient (ie the problem is that everyone is being redirected to the same page, without differentiating who is responding to the questionnaire).

    
asked by anonymous 12.06.2017 / 13:41

1 answer

0

You can do this using the ?_GET method, it would look like this:

<td><a href='sala_questionario.php?id=$row['id']'><button class='btn btn-info'>Redirecionar</button></a></td>

And on page sala_questionario , for you to get the value, it would look like this:

$id = $_GET["id"];
    
12.06.2017 / 13:58