Return results from database

Asked

Viewed 25 times

-1

Good personal day I am new in programming I am creating a system of consultation and registration of users, but I am not able to return the items already registered

include_once("ConexaoBigData.php");

$nome = $_POST['Nome'];
$email = $_POST['Email'];

$sql = "insert into Funcionarios (Nome,Email) values ($nome, $email)";

 $salvar = mysqli_query($conexao,$sql);

 $linha = mysqli_affected_rows($conexao);


mysqli_close($conexao);
  • I don’t understand, you can’t return, this is just talk to select, and why you put an Insert?

  • I ended up confusing, in this case would be Select * from and the table name Thanks !

  • Edit your question by placing the code pertinent to the difficulty

  • Use which version of PHP? It might be interesting to use PDO also https://www.php.net/manual/en/book.pdo.php

1 answer

0

You are only doing the Insert. Try so:

include_once("ConexaoBigData.php");

$nome = $_POST['Nome'];
$email = $_POST['Email'];

$sql = "insert into Funcionarios (Nome,Email) values ($nome, $email)";

 $salvar = mysqli_query($conexao,$sql);

 $linha = mysqli_affected_rows($conexao);

$funcionarios = mysqli_query($conexao, "select * from Funcionarios");

mysqli_close($conexao);

With this you will have populated the variable employees with the existing records in the table and you can use it wherever you want in your code.

Browser other questions tagged

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