How to register, query and display data on the same request?

0

I have a form where the user inserts his data (name, experience, height and weight), the information is registered in the bank, compared and is returned to the user the ideal board model according to his information, within a modal . All this is already done and working.

The problem is that obviously, as SELECT is already inside the code, once the page is loaded the REQUEST in the database is already done! And I have as feedback the last user who registered your information in the bank.

The user has to enter his data in form , his data is registered in the bank, the comparison is made and the return with the result is displayed in the same request.

Sofar,whatI'vedone:

HeretheSELECTismade.ComparingthedataintheDB:

functionBuscaAlgo($conexao){$query="SELECT  USU.usuario,
                 USU.nome,
                 USU.exp,
                 USU.altura,
                 USU.peso,
                 PRAN.exp_ref,
                 PRAN.altura_ref,
                 PRAN.peso_ref,
                 PRAN.tipo_prancha,
                 PRAN.tamanho_prancha, 
                 PRAN.meio_prancha, 
                 PRAN.litragem_prancha       
                  FROM DADOS_USUARIO AS USU 
                       INNER JOIN PRANCHA AS PRAN
                           on USU.exp = PRAN.exp_ref
                            WHERE USU.altura = PRAN.altura_ref
                              AND USU.peso = PRAN.peso_ref
                                ORDER BY USU.usuario DESC LIMIT 1"; 

  $resultado = mysqli_query($conexao,$query);

  $retorno = array();

  while($experiencia = mysqli_fetch_assoc($resultado)){
    $retorno[] = $experiencia;
  }
 return $resultado;
} 

Here it shows the result of the SELECT done in the database:

include "banco.php";    

$resultado = array();
$resultado = BuscaAlgo($conexao);

foreach($resultado as $valor){
  echo $valor['usuario']; print('.  .'); 
  echo $valor['nome']; print('.  .'); 
  echo $valor['exp']; print('.  .'); 
  echo $valor['altura']; print('.  .'); 
  echo $valor['peso']; print('.  .'); 
  print('///////');
  echo $valor['tipo_prancha']; print('.  .'); 
  echo $valor['tamanho_prancha']; print('.  .'); 
  echo $valor['meio_prancha']; print('.  .'); 
  echo $valor['litragem_prancha'];  
}

(Ignore the visual part. At this point, the goal is only to bring the same result.)

How can I do this within the same request? What is the best way to do it and how?

    
asked by anonymous 17.06.2016 / 17:35

0 answers