0
I’m trying to list the database data, only when I try to list it returns the error:
Uncaught Argumentcounterror: Too few Arguments to Function processes::__Construct(), 0 passed in
When I declare the variables in $mostra = new processa(*);
it returns me the following error:
Undefined variable: name in
My index code:
<div class="container">
<?php $mostra = new processa($nome, $email, $telefone);
$mostra->listaru($conn);
if (!empty($mostra)): ?>
<table class="table">
<thead class="thead-dark">
<tr align="center">
<th scope="col">Nome</th>
<th scope="col">Email</th>
<th scope="col">Telefone</th>
</tr>
</thead>
<tbody>
<?php while ($row = $mostra->fetch_assoc()): ?>
<tr>
<td>
<?= $row['nome'] ?>
</td>
<td>
<?= $row['email'] ?>
</td>
<td>
<?= $row['telefone'] ?>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
<?php endif; ?>
</div>
php classes.:
class processa {
private $nome, $email, $telefone;
public function __construct($nome, $email, $telefone) {
$this->nome = $nome;
$this->telefone = $telefone;
$this->email = $email;
}
}
class processa {
private $nome, $email, $telefone;
public function __construct($nome, $email, $telefone) {
$this->nome = $nome;
$this->telefone = $telefone;
$this->email = $email;
}
public function listaru($conn) {
$puxar = "SELECT * FROM usuario;";
return $conn->query($puxar);
}
}
He comes to show the <thead>
table, just does not show the contents of the <tbody>
.
in
Processa
you are required to inform the three arguments in the constructor.– rray
Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).
– Maniero