// esta é uma pagina separada, chamada adicionar_consulta.php
<?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
FROM paciente, ficha_atendimento
WHERE paciente.id = ficha_atendimento.id_paciente
AND ficha_atendimento.id IN (SELECT MIN(id) FROM
ficha_atendimento)
AND ficha_atendimento.status IS TRUE");
while ($row = $res->fetch_assoc()) {
echo " id = " . $row['nome'] . " " . $row['idade']. "</br>";
}
?>
I want to display the data of this query in PHP on the same page as the calling button. This code above is the query script. By pressing the button it is performed, but a redirect to another page occurs.