1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| <?php
$bdd = new PDO('mysql:host=localhost;dbname=db', 'user', 'mdp');
if(isset($_SESSION['id']) AND !empty($_SESSION['id'])) {
$msg = $bdd->prepare('SELECT * FROM messages WHERE id_destinataire = ? order BY id DESC');
$msg->execute(array($_SESSION['id']));
$msg_nbr = $msg->rowCount();
?>
<h3>Votre boîte de réception:</h3>
<?php
if($msg_nbr == 0) { echo "Vous n'avez aucun message..."; }
while($m = $msg->fetch()) {
$p_exp = $bdd->prepare('SELECT pseudo FROM membres WHERE id = ? order BY id DESC');
$p_exp->execute(array($m['id_expediteur']));
$p_exp = $p_exp->fetch();
$p_exp = $p_exp['pseudo'];
?>
<b><?= $p_exp ?></b> vous a envoyé: <br />
<?= nl2br($m['message']) ?><br />
-------------------------------------<br/>
<?php } ?>
<?php } ?> |