0
I wanted to know how I could display this data:
<?php
// session_start();
include("conexao.php");//chama o arquivo que faz a conexão com o banco
$sql = mysqli_query($conn, "select * from usuarios order by nome asc");//"joga" a query na variavel sql
//a variavel exibe é para exibir os dados da lista do banco
while($exibe = mysqli_fetch_assoc($sql)){
echo $exibe["id"];
echo $exibe["nome"];
echo $exibe["email"];
echo $exibe["senha"];
echo $exibe["telefone"];
}
?>
Which are being displayed with echo for a list on Html5:
<form method="POST"action="lista.php">
<table class="table table-dark">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Nome</th>
<th scope="col">E-mail</th>
<th scope="col">Telefone</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</form>
I did the test with echo to see if it would work and yes I can pull the items from my database, in case, phpMyAdmin.
while Kayo was open
– gmsantos
True, thank you @gmsantos.
– Kayo Bruno
I’m sorry but I didn’t understand why the $data variable ? it was created at that time so that ?
– Marcelo L
Notice: Undefined variable: sql in C: xampp htdocs testephp listaPage.php on line 93 Warning: mysqli_fetch_assoc() expects Parameter 1 to be mysqli_result, null Given in C: xampp htdocs testephp listaphp Page.php on line 93 These lines appear when I try to run the project after putting its code @Kayobruno
– Marcelo L
@Marcelol, this is just the name chosen to capture the return, instead of
$data
could still be the one you created,$exibe
hassle-free– Dimas Pante
@Marcelol, about the error, checks if you have this database query line (select *...) with this variable name,
$sql
– Dimas Pante
$result_usuarios = "SELECT * FROM usuarios"; $resultado_usuarios = mysqli_query($Conn, $result_usuarios); this is my "list.php" where I connect to the database and call it at the beginning of the list
– Marcelo L
@Dimaspante forgot to mark kkk
– Marcelo L
@Marcelol, tranquil. So, just you change the variable inside that mysqli_fetch_assoc, from
$sql
for$result_usuarios
– Dimas Pante
@Dimaspante ai que ta...ja testei e da isso aqui Notice: Undefined variable: result_usuarios in C: xampp htdocs testephp listaPage.php on line 106
– Marcelo L
Let’s go continue this discussion in chat.
– Dimas Pante