Bonjour, j'ai installer une messagerie interne sur mon site, j'ai pris un script déjà tout fait, sauf qu'il est un peu mal fait.
Il n'y à pas la possibilité de supprimer une conversation
pouvez vous m'aider à ajouter un bouton "supprimer" qui effacerai une conversation
merci
<?php
/*
*/
$titre = 'Gestion des vidéos';
require ('head.php');
?>
<div id="content">
<div id="page">
<div class="inner">
<div class="section">
<div class="title_wrapper">
<h2>Messagerie</h2>
<span class="title_wrapper_left"></span>
<span class="title_wrapper_right"></span>
</div>
<div class="section_content">
<div class="sct">
<div class="sct_left">
<div class="sct_right">
<div class="sct_left">
<div class="sct_right">
<?php
include('config.php');
?>
<link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="Style" />
<div class="content">
<?php
//On verifie que lutilisateur est connecte
if(isset($_SESSION['username']))
{
//On affiche la liste des messages de l'utilisateur sous la forme dun tableau
//Deux requettes sont executees, une pour recuperer les messages non-lus et une pour les messages lus
$req1 = mysql_query('select m1.id, m1.title, m1.timestamp, count(m2.id) as reps, users.id as userid, users.username from pm as m1, pm as m2,users where ((m1.user1="'.$_SESSION['userid'].'" and m1.user1read="no" and users.id=m1.user2) or (m1.user2="'.$_SESSION['userid'].'" and m1.user2read="no" and users.id=m1.user1)) and m1.id2="1" and m2.id=m1.id group by m1.id order by m1.id desc');
$req2 = mysql_query('select m1.id, m1.title, m1.timestamp, count(m2.id) as reps, users.id as userid, users.username from pm as m1, pm as m2,users where ((m1.user1="'.$_SESSION['userid'].'" and m1.user1read="yes" and users.id=m1.user2) or (m1.user2="'.$_SESSION['userid'].'" and m1.user2read="yes" and users.id=m1.user1)) and m1.id2="1" and m2.id=m1.id group by m1.id order by m1.id desc');
?>
Voici la liste de vos messages:<br />
<a href="message_new.php" class="link_new_pm">Nouveau message privé</a><br />
<h3>Messages non-lus(<?php echo intval(mysql_num_rows($req1)); ?> ):</h3>
<table>
<tr>
<th class="title_cell">Titre</th>
<th>Nb. Réponses</th>
<th>Participant</th>
<th>Date d'envoi</th>
</tr>
<?php
//On affiche la liste des messages non-lus
while($dn1 = mysql_fetch_array($req1))
{
?>
<tr>
<td class="left"><a href="message_read.php?id=<?php echo $dn1['id']; ?>"><?php echo htmlentities($dn1['title'], ENT_QUOTES, 'UTF-8'); ?></a></td>
<td><?php echo $dn1['reps']-1; ?></td>
<td><a href="#"><?php echo htmlentities($dn1['username'], ENT_QUOTES, 'UTF-8'); ?></a></td>
<td><?php echo date('d/m/Y H:i:s' ,$dn1['timestamp']); ?></td>
</tr>
<?php
}
//Sil na aucun message non-lu, on le dit
if(intval(mysql_num_rows($req1))==0)
{
?>
<tr>
<td colspan="4" class="center">Vous n'avez aucun message non-lu.</td>
</tr>
<?php
}
?>
</table>
<br />
<h3>Messages lus(<?php echo intval(mysql_num_rows($req2)); ?> ):</h3>
<table>
<tr>
<th class="title_cell">Titre</th>
<th>Nb. Réponses</th>
<th>Participant</th>
<th>Date d'envoi</th>
</tr>
<?php
//On affiche la liste des messages lus
while($dn2 = mysql_fetch_array($req2))
{
?>
<tr>
<td class="left"><a href="message_read.php?id=<?php echo $dn2['id']; ?>"><?php echo htmlentities($dn2['title'], ENT_QUOTES, 'UTF-8'); ?></a></td>
<td><?php echo $dn2['reps']-1; ?></td>
<td><a href="#"><?php echo htmlentities($dn2['username'], ENT_QUOTES, 'UTF-8'); ?></a></td>
<td><?php echo date('d/m/Y H:i:s' ,$dn2['timestamp']); ?></td>
</tr>
<?php
}
//Sil na aucun message lu, on le dit
if(intval(mysql_num_rows($req2))==0)
{
?>
<tr>
<td colspan="4" class="center">Vous n'avez aucun message lu.</td>
</tr>
<?php
}
?>
</table>
<?php
}
else
{
echo 'Vous devez être connecté pour accéder à cette page.';
}
?>
</div>
</body>
</html>
</div>
</div>
</div>
</div>
</div>
<span class="scb"><span class="scb_left"></span><span class="scb_right"></span></span>
</div>
</div>
</div>
</div>
<?php
require ('foot.php');
?>
Code : Tout sélectionner
- Structure de la table `users`
--
CREATE TABLE `users` (
`id` bigint(20) NOT NULL,
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`avatar` text NOT NULL,
`signup_date` int(10) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Structure de la table `pm`
--
CREATE TABLE `pm` (
`id` bigint(20) NOT NULL,
`id2` int(11) NOT NULL,
`title` varchar(256) NOT NULL,
`user1` bigint(20) NOT NULL,
`user2` bigint(20) NOT NULL,
`message` text NOT NULL,
`timestamp` int(10) NOT NULL,
`user1read` varchar(3) NOT NULL,
`user2read` varchar(3) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;