0
I have a function within my class to list data; below follows the code:
public function listadados(){
try{
//retornar um array
$sql = "SELECT * FROM web_cadcli";
$lista = $this->con->conectar()->prepare($sql);
$lista->execute();
$retDados = array ( $lista-> fetchAll(PDO::FETCH_ASSOC));
print_r($retDados);
}catch(PDOException $erro_2){
echo 'erro'.$erro_2->getMessage();
}
}
I want to put the return that is below. within an html
Array
(
[0] => Array
(
[0] => Array
(
[idcad_cliente] => 1
[nm_cliente] => Rodrigo Zanetti
[email_cliente] => [email protected]
[senha_cliente] => 7ik3ikelek
[id_identpess] => 1
[img] =>
)
[1] => Array
(
[idcad_cliente] => 2
[nm_cliente] => Rodrigo Zanetti
[email_cliente] => [email protected]
[senha_cliente] => k3ik3ik3ikkejeh
[id_identpess] => 1
[img] =>
)
[2] => Array
(
[idcad_cliente] => 3
[nm_cliente] => Adriana Silva Souto
[email_cliente] => [email protected]
[senha_cliente] => k3ikeikeikeieçeoel
[id_identpess] => 1
[img] =>
)
This screen below is my template, where I want to return the formatted values. name below NAME: email below EMAIL, as a table.
listed(); ?> <table class="table table-striped table-bordered table-hover">
<thead>
<tr class="active">
<th>Nome</th>
<th>E-mail</th>
<th>Editar</th>
<th>Deletar</th>
</tr>
</thead>
<tbody>
</table>
Why don’t you do
return $retDados
in its method and use theforeach
to browse them, displaying in HTML?– Woss