<?php include('partie1_admin.php');?>
<div id="coverer" align="center">
<h2><img src="img/fleche.gif" style="margin-bottom:-10px;" height="40" width="40">&nbsp;Contacts</h2>

<?php 

function pluriel($message)
{
	if ($message>1)
	
{
	$plur="s";
}
else
{
$plur="";
}
return $plur;
}
include('connexion_mysql.php');

if (isset($_GET['supprimer_news'])) // Si l'on demande de supprimerune news.
{
// Alors on supprime la news correspondante.
// On protège la variable « id_news » pour éviter une faille SQL
$_GET['supprimer_news'] = addslashes($_GET['supprimer_news']);
$retour = 'DELETE FROM messages WHERE id=\'' .
$_GET['supprimer_news'] . '\'';
$res = $conn->query($retour);
}?>

<table><tr>
<th>Objets</th>
<th>Messages</th>
<th>Consulter</th>
</tr>
<?php         
$retourx = 'SELECT * FROM objet ORDER BY id ASC limit 0,4';
$res = $conn->query($retourx);	
while($donneesobj = mysqli_fetch_array($res))
{
$objet = stripslashes($donneesobj['libelle']);
$id_objet = stripslashes($donneesobj['id']);?>

<tr align="center">
<td><?php echo $objet;?></td>
<td><?php $retour1 = "SELECT COUNT(message) as total_message FROM messages WHERE objet='".$objet."' ";
$res2 = $conn->query($retour1);
$row = mysqli_fetch_assoc($res2);
$plur=pluriel($row["total_message"]);
echo $row["total_message"]." message".$plur;?></td>
<td>
<?php echo '<a href="consulter_messages.php?id='.$objet.'">';
$_SESSION['total_message1'] = $row["total_message"];?>Consulter</a></td>
</tr>

<?php } ?>


</table>
<?php include('partie3_admin.php'); ?>