0
php is showing only 1 value in the tables, I needed it to show all, one below the other.
<?php require 'pages/header.php'; ?>
<?php
if(empty($_SESSION['cLogin'])) {
?>
<script type="text/javascript">window.location.href="login.php";</script>
<?php
exit;
}
?>
<div class="container">
<h1>Controle de Clientes | Agro Grama</h1>
<a href="add-clientes.php" class="btn btn-success">Adicionar Clientes</a>
<table class="table table-striper">
<thead>
<tr>
<th>Nome</th>
<th>E-mail</th>
<th>Telefone</tb>
<th>Endereço</th>
<th>Cidade</tb>
<th>Firma</th>
<th>CNPJ</th>
<th>CPF</th>
</tr>
</thead>
<tr>
<td>
<?php
$sql = $pdo->prepare("SELECT nome AS nome FROM clientes");
$sql->execute();
$ln = $sql->fetchObject();
echo ($ln->nome);
?></th>
</td>
<td>
<?php
$sql = $pdo->prepare("SELECT email AS email FROM clientes");
$sql->execute();
$ln = $sql->fetchObject();
echo ($ln->email);
?>
</td>
<td>
<?php
$sql = $pdo->prepare("SELECT telefone AS telefone FROM clientes");
$sql->execute();
$ln = $sql->fetchObject();
echo ($ln->telefone);
?>
</td>
<td>
<?php
$sql = $pdo->prepare("SELECT endereco AS endereco FROM clientes");
$sql->execute();
$ln = $sql->fetchObject();
echo ($ln->endereco);
?>
</td>
<td>
<?php
$sql = $pdo->prepare("SELECT cidade AS cidade FROM clientes");
$sql->execute();
$ln = $sql->fetchObject();
echo ($ln->cidade);
?>
</td>
<td>
<?php
$sql = $pdo->prepare("SELECT firma AS firma FROM clientes");
$sql->execute();
$ln = $sql->fetchObject();
echo ($ln->firma);
?>
</td>
<td>
<?php
$sql = $pdo->prepare("SELECT cnpj AS cnpj FROM clientes");
$sql->execute();
$ln = $sql->fetchObject();
echo ($ln->cnpj);
?>
<td>
<?php
$sql = $pdo->prepare("SELECT cpf AS cpf FROM clientes");
$sql->execute();
$ln = $sql->fetchObject();
echo ($ln->cpf);
?>
</td>
</tr>
<tr>
</tr>
</table>
</div>
<?php require 'pages/footer.php'; ?>
You are making a query for each field(8 in total), what you need is a
while
and for each row show the various fields– Isac
Sorry, I’m new to PHP, but you can answer my code with the while for me to see?
– Marcos A. Massini