3
Well, I’ve been doing some research, I found several topics talking about it, but none of them were useful to me, so I decided to turn to Stack Overflow.
I have a role to list all user tickets that are open:
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());
}
}
Until then beauty, let’s go to the main, I have in my html, a while
where I put all my code pad HTML
, but when I use the while
, it captures only 1 data from my table and goes into 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.
I already tried, returns me the following error:
Notice: Undefined offset: 1
.– Guilherme SpinXO