1
Hello, I’m having trouble collecting information from users of a database.
In DB there are some users, and they are displayed in a table.
My goal is that when the names are clicked, a Collapse occurs that shows all the information of the clicked user, but when clicked occurs the error:
Undefined index
Follows the code:
<div class="row" id="realTimeContents myGroup">
<div class="col-md-8">
<div class="scrollable">
<table class="table table-striped table-dark text-center">
<thead>
<tr>
<td>ID</td>
<td>Nome</td>
<td>CPF/CNPJ</td>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT * FROM registro";
$result = mysqli_query($conexao, $sql);
$queryResults = mysqli_num_rows ($result);
if ($queryResults > 0) {
while ($row = mysqli_fetch_assoc($result)) {
echo "<tr>
<td scope='row'>".$row['id']."</td>
<td><a class='' data-toggle='collapse' aria-expanded='false' aria-controls='teste' href='#teste'?nome=".$row['nome']."&CPF=".$row['CPF']."'>".$row['nome']."</a></td>
<td>".$row['CPF']."</td>
</tr>";
}
}
?>
</tbody>
<!-- collpse user content -->
<div class="collapse" id="teste">
<?php
$nome = mysqli_real_escape_string($conexao, $_GET['nome']);
$CPF = mysqli_real_escape_string($conexao, $_GET['CPF']);
$sql = "SELECT * FROM registro WHERE nome='$nome' AND CPF='$CPF'";
$result = mysqli_query($conexao, $sql);
$queryResults = mysqli_num_rows ($result);
if ($queryResults > 0) {
while ($row = mysqli_fetch_assoc($result)) {
echo "<td>".$row['nome']."</td>
<td>".$row['CPF']."</td>
<td>".$row['data_de_nascimento']."</td>
<td>".$row['numero_de_cadastro']."</td>
<td>".$row['CEP']."</td>
<td>".$row['numero']."</td>
<td>".$row['bairro']."</td>
<td>".$row['endereço']."</td>
<td>".$row['cidade']."</td>
<td>".$row['complemento']."</td>
<td>".$row['uf']."</td>
<td>".$row['telefone_residencial']."</td>
<td>".$row['telefone_comercial']."</td>
<td>".$row['categoria_de_cliente']."</td>
<td>".$row['telefone_celular']."</td>
<td>".$row['telefone_0800']."</td>
<td>".$row['insc_estadual']."</td>
<td>".$row['CNPJ']."</td>
<td>".$row['RG']."</td>
<td>".$row['insc_municipal']."</td>
<td>".$row['PIS']."</td>
<td>".$row['site']."</td>
<td>".$row['email']."</td>
<td>".$row['historico']."</td>";
}
}
?>
</div>
</table>
</div>
</div>
</div>
Table structure:
The format I used to try to show all user information is experimental, no problem if there is a better way to do this process.
I’m sorry if you seemed confused, I tried to be as clear as I could be.
From now on, thank you for your patience!
unfortunately you will have to debug to find the problem I would try to var_dump this code starting with $Row!
– Lodi
It would be interesting if you used ajax, that the loading would be faster.
– Vinicius De Jesus
@I’ll try, thanks for the tip
– Nithogg
@Viniciusdejesus I don’t know how to do it but I’ll see how it works ;D
– Nithogg