I have a page where the intention is to upload a series of messages received by a user. For that in the principle of loading the page I do the following:
<?php
$conexion = new Conexion();
$sql = "SELECT id, fecha_hora, remitente, asunto FROM mensajes WHERE destinatario = :valor";
$stmt = $conexion -> prepare($sql);
$stmt->bindParam(':valor', $_SESSION['id_usuario']);
$stmt->execute();
?>
Below, in the body of the page I do the following:
<table class="ui padded stackable table">
<thead >
<tr>
<th hidden>Id</th>
<th>Fecha</th>
<th>Remitente</th>
<th>Asunto</th>
</tr>
</thead>
<tbody>
<?php while($resultado = $stmt->fetch()) { ?>
<tr>
<td hidden><?php echo $resultado['id'];?></td>
<td><?php echo $resultado['fecha_hora'];?></td>
<td><?php echo $resultado['remitente'];?></td>
<td><?php echo $resultado['asunto'];?></td>
</tr>
<?php } ?>
</tbody>
The strangest thing of all this is that the same structure I make it in other pages with other tables that I fill with the same system but in this case it does not load anything. I made several modifications to see that the data is loaded, in fact I did the happy while following where I do the $ stmt-> execute () and I have placed two echoes to show the records and I SHOW THEM !!! ... now because he does not show them in the table, I do not understand ...
Look at the following: I do this in the header of the page and it returns the bottom image:
$conexion = new Conexion();
$sql = "SELECT id, fecha_hora, remitente, asunto FROM mensajes WHERE destinatario = :valor";
$stmt = $conexion->prepare($sql);
$stmt->bindParam(':valor', $_SESSION['id_usuario']);
$resultado = $stmt->execute();
while($resultado = $stmt->fetch()) {
echo $resultado['id'] . "<br>";
echo $resultado['fecha_hora'] . "<br>";
echo $resultado['remitente'] . "<br>";
echo $resultado['asunto'] . "<br>";
}
HOW IS THIS POSSIBLE ????