File "filtre.php"

Full Path: /home/analogde/www/Freebox/CHESS_ON/filtre.php
File size: 11.84 KB
MIME-type: text/x-php
Charset: utf-8

<?php

	include('database.php');
	DB_connexion(); 

	$J1 = $_POST['J1'];
	$J2 = $_POST['J2'];
	$choix1 = $_POST['choix1'];
	$choix2 = $_POST['choix2'];
	$choix3 = $_POST['choix3'];
	$resultat = $_POST['resultat'];
	
	/*echo $J1;
	echo $J2;
	echo $choix1;
	echo $choix2;
	echo $choix3;*/
	/*echo $resultat;*/
	
	$number = 0;
/****************************************************************/	
	if($choix1 == "no" && $choix2 == "no" && $choix3 == "no")
	{  
		echo "Aucun résultat: Le filtre n'est pas actif";
	}
/****************************************************************/	
	if($choix1 == "ok" && $choix2 == "no" && $choix3 == "no")
	{  
	    $sql = "SELECT * FROM partie WHERE joueur1 = '".$J1."'";
		$results1 = mysql_query($sql);
		$sql = "SELECT * FROM partie WHERE joueur2 = '".$J1."'";
		$results2 = mysql_query($sql);
		$n1 = mysql_num_rows($results1);
		$n2 = mysql_num_rows($results2);
		$number = $n1 + $n2;
		echo "Nombre de réponses: "  .$number;
		
		if($number != 0)
		{
			echo '<div id="affiche_resultat">';
			echo '	<table border="1">
					<tr>
					<th class="center" width="60">Joueur 1</th>
					<th class="center" width="60">Joueur 2</th>
					<th class="center" width="120">Résultat</th>
					<th class="center" width="120">Score</th>
					<th class="center" width="100">Date</th>
					<th class="center" width="100">Heure</th>
					</tr>';
				
			while($data = mysql_fetch_assoc($results1)) 
		    {	
		     	$J1 = $data['joueur1'];
				$J2 = $data['joueur2'];
				$resultat_partie = $data['resultat_partie'];
				$score = $data['score_joueur1'];
				$date = $data['date_partie'];
				$heure = $data['heure_partie'];
				echo "<tr> 
					  <td align=center width='60'> $J1 </td> 
					  <td align=center width='60'> $J2 </td> 
					  <td align=center width='120'> $resultat_partie </td>
					  <td align=center width='120'> $score </td>
					  <td align=center width='100'> $date </td>
					  <td align=center width='100'> $heure </td>	
					  </tr>";
		    }						
			while($data = mysql_fetch_assoc($results2)) 
		    {	
				$J1 = $data['joueur1'];
				$J2 = $data['joueur2'];
				$resultat_partie = $data['resultat_partie'];
				$score = $data['score_joueur2'];
				$date = $data['date_partie'];
				$heure = $data['heure_partie'];
				echo "<tr> 
					  <td align=center width='60'> $J2 </td> 
					  <td align=center width='60'> $J1 </td>
					  <td align=center width='120'> $resultat_partie </td>
					  <td align=center width='120'> $score </td>
					  <td align=center width='100'> $date </td>
					  <td align=center width='100'> $heure </td>	
					  </tr>";	  
		    }		
			echo "</table>";
			echo '</div>';
		}
		
	}

/****************************************************************/	
	if($choix1 == "ok" && $choix2 == "ok" && $choix3 == "no")
	{  
		
		$sql = "SELECT * FROM partie WHERE joueur1 = '".$J1."' AND joueur2 = '".$J2."' ";
		$results1 = mysql_query($sql);
		$sql = "SELECT * FROM partie WHERE joueur2 = '".$J1."' AND joueur1 = '".$J2."' ";
		$results2 = mysql_query($sql);
		$n1 = mysql_num_rows($results1);
		$n2 = mysql_num_rows($results2);
		$number = $n1 + $n2;
		echo "Nombre de réponses: "  .$number;
		
		if($number != 0)
		{
			echo '<div id="affiche_resultat">';
			echo '	<table border="1">
					<tr>
					<th class="center" width="60">Joueur 1</th>
					<th class="center" width="60">Joueur 2</th>
					<th class="center" width="120">Résultat</th>
					<th class="center" width="100">Date</th>
					<th class="center" width="100">Heure</th>
					</tr>';
				
			while($data = mysql_fetch_assoc($results1)) 
		    {	
		     	$J1 = $data['joueur1'];
				$J2 = $data['joueur2'];
				$resultat_partie = $data['resultat_partie'];
				$date = $data['date_partie'];
				$heure = $data['heure_partie'];
				echo "<tr> 
					  <td align=center width='60'> $J1 </td> 
					  <td align=center width='60'> $J2 </td> 
					  <td align=center width='120'> $resultat_partie </td>
					  <td align=center width='100'> $date </td>
					  <td align=center width='100'> $heure </td>	
					  </tr>";
		    }						
			while($data = mysql_fetch_assoc($results2)) 
		    {	
				$J1 = $data['joueur1'];
				$J2 = $data['joueur2'];
				$resultat_partie = $data['resultat_partie'];
				$date = $data['date_partie'];
				$heure = $data['heure_partie'];
				echo "<tr> 
					  <td align=center width='60'> $J2 </td> 
					  <td align=center width='60'> $J1 </td>
					  <td align=center width='120'> $resultat_partie </td>
					  <td align=center width='100'> $date </td>
					  <td align=center width='100'> $heure </td>	
					  </tr>";	  
		    }		
			echo "</table>";
			echo '</div>';
		}
		
	}
/*************************************************************/
	
	if($choix1 == "ok" && $choix2 == "no" && $choix3 == "ok")
	{  
		
		$sql = "SELECT * FROM partie WHERE joueur1 = '".$J1."' AND resultat_partie = '".$resultat."' ";
		$results1 = mysql_query($sql);
		$sql = "SELECT * FROM partie WHERE joueur2 = '".$J1."' AND resultat_partie = '".$resultat."' ";
		$results2 = mysql_query($sql);
		$n1 = mysql_num_rows($results1);
		$n2 = mysql_num_rows($results2);
		$number = $n1 + $n2;
		echo "Nombre de réponses: "  .$number;
		
		if($number != 0)
		{
			echo '<div id="affiche_resultat">';
			echo '	<table border="1">
					<tr>
					<th class="center" width="60">Joueur 1</th>
					<th class="center" width="60">Joueur 2</th>
					<th class="center" width="120">Résultat</th>
					<th class="center" width="100">Date</th>
					<th class="center" width="100">Heure</th>
					</tr>';
				
			while($data = mysql_fetch_assoc($results1)) 
		    {	
		     	$J1 = $data['joueur1'];
				$J2 = $data['joueur2'];
				$resultat_partie = $data['resultat_partie'];
				$date = $data['date_partie'];
				$heure = $data['heure_partie'];
				echo "<tr> 
					  <td align=center width='60'> $J1 </td> 
					  <td align=center width='60'> $J2 </td> 
					  <td align=center width='120'> $resultat_partie </td>
					  <td align=center width='100'> $date </td>
					  <td align=center width='100'> $heure </td>	
					  </tr>";
		    }						
			while($data = mysql_fetch_assoc($results2)) 
		    {	
				$J1 = $data['joueur1'];
				$J2 = $data['joueur2'];
				$resultat_partie = $data['resultat_partie'];
				$date = $data['date_partie'];
				$heure = $data['heure_partie'];
				echo "<tr> 
					  <td align=center width='60'> $J2 </td> 
					  <td align=center width='60'> $J1 </td>
					  <td align=center width='120'> $resultat_partie </td>
					  <td align=center width='100'> $date </td>
					  <td align=center width='100'> $heure </td>	
					  </tr>";	  
		    }		
			echo "</table>";
			echo '</div>';
		}
		
	}

/*************************************************************/
	
	if($choix1 == "ok" && $choix2 == "ok" && $choix3 == "ok")
	{  
		
		$sql = "SELECT * FROM partie WHERE joueur1 = '".$J1."' AND joueur2 = '".$J2."' AND resultat_partie = '".$resultat."' ";
		$results1 = mysql_query($sql);
		$sql = "SELECT * FROM partie WHERE joueur2 = '".$J1."' AND joueur1 = '".$J2."' AND resultat_partie = '".$resultat."' ";
		$results2 = mysql_query($sql);
		$n1 = mysql_num_rows($results1);
		$n2 = mysql_num_rows($results2);
		$number = $n1 + $n2;
		echo "Nombre de réponses: "  .$number;
		
		if($number != 0)
		{
			echo '<div id="affiche_resultat">';
			echo '	<table border="1">
					<tr>
					<th class="center" width="60">Joueur 1</th>
					<th class="center" width="60">Joueur 2</th>
					<th class="center" width="120">Résultat</th>
					<th class="center" width="100">Date</th>
					<th class="center" width="100">Heure</th>
					</tr>';
				
			while($data = mysql_fetch_assoc($results1)) 
		    {	
		     	$J1 = $data['joueur1'];
				$J2 = $data['joueur2'];
				$resultat_partie = $data['resultat_partie'];
				$date = $data['date_partie'];
				$heure = $data['heure_partie'];
				echo "<tr> 
					  <td align=center width='60'> $J1 </td> 
					  <td align=center width='60'> $J2 </td> 
					  <td align=center width='120'> $resultat_partie </td>
					  <td align=center width='100'> $date </td>
					  <td align=center width='100'> $heure </td>	
					  </tr>";
		    }						
			while($data = mysql_fetch_assoc($results2)) 
		    {	
				$J1 = $data['joueur1'];
				$J2 = $data['joueur2'];
				$resultat_partie = $data['resultat_partie'];
				$date = $data['date_partie'];
				$heure = $data['heure_partie'];
				echo "<tr> 
					  <td align=center width='60'> $J2 </td> 
					  <td align=center width='60'> $J1 </td>
					  <td align=center width='120'> $resultat_partie </td>
					  <td align=center width='100'> $date </td>
					  <td align=center width='100'> $heure </td>	
					  </tr>";	  
		    }		
			echo "</table>";
			echo '</div>';
		}
		
	}	
	
/*************************************************************/
	
	if($choix1 == "no" && $choix2 == "no" && $choix3 == "ok")
	{  
		
		$sql = "SELECT * FROM partie WHERE resultat_partie = '".$resultat."' ";
		$results1 = mysql_query($sql);
		$number = mysql_num_rows($results1);
		echo "Nombre de réponses: "  .$number;
		
		if($number != 0)
		{
			echo '<div id="affiche_resultat">';
			echo '	<table border="1">
					<tr>
					<th class="center" width="60">Joueur 1</th>
					<th class="center" width="60">Joueur 2</th>
					<th class="center" width="120">Résultat</th>
					<th class="center" width="100">Date</th>
					<th class="center" width="100">Heure</th>
					</tr>';
				
			while($data = mysql_fetch_assoc($results1)) 
		    {	
		     	$J1 = $data['joueur1'];
				$J2 = $data['joueur2'];
				$resultat_partie = $data['resultat_partie'];
				$date = $data['date_partie'];
				$heure = $data['heure_partie'];
				echo "<tr> 
					  <td align=center width='60'> $J1 </td> 
					  <td align=center width='60'> $J2 </td> 
					  <td align=center width='120'> $resultat_partie </td>
					  <td align=center width='100'> $date </td>
					  <td align=center width='100'> $heure </td>	
					  </tr>";
		    }						
			
			echo "</table>";
			echo '</div>';
		}
		
	}		
	
/*************************************************************/
	
	/*echo $resultat;*/
	
	/*$sql = "SELECT * FROM joueurs WHERE nom = '".$q."'";

	$sql = "SELECT * FROM joueurs WHERE nom = '".$q."'";
	
	$J1 = "dddd";
	$J2 = $J1;*/
	
	//$sql = "(SELECT * from partie where joueur1='$q' ) union (SELECT * from partie where resultat_partie='$z')";
	
	/*<option>J1 gagne</option>
	<option>J1 perd</option>
	<option>J2 gagne</option>
	<option>J2 perd</option>
	<option>Match nul</option>*/
/*		
	$sql = "SELECT * FROM partie WHERE joueur1 = '$q' AND resultat_partie = '$z' ";
	$results = mysql_query($sql);
	$number = mysql_num_rows($results);

	echo "Nombre de réponses: "  .$number;*/
	/*
	if($number != 0)
	{
		echo '<div id="affiche_resultat">';
		echo '	<table border="1">
				<tr>
				<th class="center" width="60">Joueur 1</th>
				<th class="center" width="60">Joueur 2</th>
				<th class="center" width="120">Résultat</th>
				<th class="center" width="100">Date</th>
				<th class="center" width="100">Heure</th>
				</tr>';
				
		while($data = mysql_fetch_assoc($results1)) 
		    {	
		     	$J1 = $data['joueur1'];
				$J2 = $data['joueur2'];
				$resultat_partie = $data['resultat_partie'];
				$date = $data['date_partie'];
				$heure = $data['heure_partie'];
				echo "<tr> 
					  <td align=center width='60'> $J1 </td> 
					  <td align=center width='60'> $J2 </td> 
					  <td align=center width='120'> $resultat_partie </td>
					  <td align=center width='100'> $date </td>
					  <td align=center width='100'> $heure </td>	
					  </tr>";
		    }						
		while($data = mysql_fetch_assoc($results2)) 
		    {	
				$J1 = $data['joueur1'];
				$J2 = $data['joueur2'];
				$resultat_partie = $data['resultat_partie'];
				$date = $data['date_partie'];
				$heure = $data['heure_partie'];
				echo "<tr> 
					  <td align=center width='60'> $J2 </td> 
					  <td align=center width='60'> $J1 </td>
					  <td align=center width='120'> $resultat_partie </td>
					  <td align=center width='100'> $date </td>
					  <td align=center width='100'> $heure </td>	
					  </tr>";	  
		    }		
		echo "</table>";
		echo '</div>';
	}*/
?>