Stack Overflow .
Stack Overflow
I have a function to list all tickets for the user who is logged in:
public function list_ticket() {
try {
$session = $_SESSION[SESSION_PREFIX . 'email_username'];
$sql = "SELECT * FROM 'tickets' WHERE email=:session ORDER BY id DESC";
$pdo = $this->connection()->prepare($sql);
$pdo->bindParam(':session', $session, PDO::PARAM_STR);
$pdo->execute();
return $pdo->fetch(PDO::FETCH_NUM);
} catch (PDOException $e) {
die('Ocorreu um erro: ' . $e->getMessage() . ' Na linha: ' . $e->getLine() . ' No arquivo: ' . $e->getFile());
}
}
So far beauty, let's go to the main one, I have in my html, a while
where I put all my code block HTML
, but when I use while
, it only captures 1 data from my table and enters in Loop Infinito
, see below the structure:
<table class="table table-striped">
<thead>
<tr>
<th>Ticket #</th>
<th>Criado em</th>
<th>Autor</th>
<th>Email</th>
<th>Assunto</th>
<th>Departamento</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php
while ($row = $ticket->list_ticket()) {
?>
<tr>
<td>
<a href="<?php echo BASE_URL; ?>"><?php echo $row[0]; ?></a>
</td>
<td>
<?php echo $row[1]; ?>
</td>
<td>
<?php echo $row[2]; ?>
</td>
<td>
<?php echo $row[3]; ?>
</td>
<td>
<?php echo $row[4]; ?>
</td>
<td>
<?php echo $row[5]; ?>
</td>
<td>
<?php
switch ($row[7]) {
case 0:
echo '<span class="label label-success">Aberto</span>';
break;
case 1:
echo '<span class="label label-info">Respondido</span>';
break;
case 2:
echo '<span class="label label-danger">Fechado</span>';
break;
}
?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
I await answers.