<?php

	session_start();
	include('database.php');
	DB_connexion(); 
	
	$filtre_utilisateur = "text3";
    echo $filtre_utilisateur;
	echo '<br/>';
	echo '<br/>'; 
	
	$msgs=mysql_query('SELECT * FROM tchat ORDER BY id DESC LIMIT 0,50');
	$cpt = 0;
								
	
								
									while($infos = mysql_fetch_array($msgs)) 
									{
								
										$champ = date('d-m-Y ', strtotime($infos["date_mess"])) ."  à  " .date(' H:i:s', strtotime($infos["date_mess"])); 
										$utilisateur = $infos["login"];
										$txt = $infos["mess"];
										$id = $infos["id"];
										$destinataires = $infos["destinataires"];
									
										$pieces = explode(",", $destinataires);
										$nb_elements = count($pieces);
										
										$flag_login = false;
										
										for($i = 0; $i < $nb_elements; $i++)
										{	$element = $pieces[$i];
										    echo $element ."   " .$utilisateur;
											echo '<br/>';
											echo '<br/>';
											if($element == $filtre_utilisateur)	
											/*$test = strcmp( $login, $element);
											if($test == 0 )*/
											{  $flag_login = true;
												echo "bof";
											}
										}
										
										echo "+++++++++++++++++++++++++++++";
										echo '<br/>';
										
										/*if($flag_login == true)
										{
											echo '-->';
											echo '<br/>';
										}*/
										//$motif = '/' .$login  .'/';
										//$motif = '/' .$login  .'/';
										//echo $motif;
										/*if(preg_match($motif,$destinataires))
										{
											echo '-->';
											echo '<br/>';
										}*/
										
										/*print_r($pieces);
										echo '<br/>';
										echo '<br/>';*/
										
										$cpt = $cpt + 1;
										
										
										/*if(in_array($login, $pieces))
										{
												echo 'one';
												echo '<br/>';
											
												$cpt = $cpt + 1;
										}*/		
									
								    }             

?>