<?php
if($_POST["submit"])
  {
	
	header('Location: aargrggrafraichir_filtre.php');
  	
        echo '<b>Formulaire validé avec les éléments : </b><br>';
	
        $portion_sql = array();
	
	if(count($critere01) != 0)
	  {
	    echo '<b>- '.$item01.' :</b> ';
	    $chaine01 ="";	
	
	    if(count($_POST[$item01]) != 0)	
	      {
    		  for($i = 0; $i < sizeof($_POST[$item01]); $i++)
	             {
			if($i > 0) echo ', ';
			echo $_POST[$item01][$i];

			$champ = $_POST[$item01][$i];

			if($i<count($_POST[$item01])-1)
		  	  {$chaine01 = $chaine01 ."'$champ'" .", ";
		  	  }
			if($i == count($_POST[$item01])-1)
		     	  {$chaine01 = $chaine01 ."'$champ'";
			  }  
	            }
		  echo "++++++++ " .$chaine01;
		
		  $final01 = $champs_filtre[0] ." IN (" .$chaine01 .")";
	    	  $portion_sql[] = $champs_filtre[0] ." IN (" .$chaine01 .")";
	    }	

	 }      
         
	echo '<br /><br />';
          
        if(count($critere02) != 0)
	  {
	    echo '<b>- '.$item02.' :</b> ';
	    $chaine02 ="";
	
	    if(count($_POST[$item02]) != 0)	
	      {	
	    	 for($i = 0; $i < sizeof($_POST[$item02]); $i++)
	            {
			if($i > 0) echo ', ';
			echo $_POST[$item02][$i];
			
			$champ = $_POST[$item02][$i];

			if($i<count($_POST[$item02])-1)
		  	  {$chaine02 = $chaine02 ."'$champ'" .", ";
		  	  }
			if($i == count($_POST[$item02])-1)
		     	  {$chaine02 = $chaine02 ."'$champ'";
			  }  
	            }
	         echo "++++++++ " .$chaine02;
	       
	         $final02 = $champs_filtre[1] ." IN (" .$chaine02 .")";
	         $portion_sql[] = $champs_filtre[1] ." IN (" .$chaine02 .")";
             }

          }  
	
	echo '<br /><br />';

	if(count($critere03) != 0)
	  {
	    echo '<b>- '.$item03.' :</b> ';
	    $chaine03 ="";	
	
	    if(count($_POST[$item03]) != 0)	
	      {
		 for($i = 0; $i < sizeof($_POST[$item03]); $i++)
	            {
			if($i > 0) echo ', ';
			echo $_POST[$item03][$i];
			
			$champ = $_POST[$item03][$i];

			if($i<count($_POST[$item03])-1)
		  	  {$chaine03 = $chaine03 ."'$champ'" .", ";
		  	  }
			if($i == count($_POST[$item03])-1)
		     	  {$chaine03 = $chaine03 ."'$champ'";
			  }  
	            }
		 echo "++++++++ " .$chaine03;
		
	         $final03 = $champs_filtre[2] ." IN (" .$chaine03 .")";
	         $portion_sql[] = $champs_filtre[2] ." IN (" .$chaine03 .")";
	     }	

          }  
	echo '<br /><br />';
          
        if(count($critere04) != 0)
	  {
	    echo '<b>- '.$item04.' :</b> ';
	    $chaine04 ="";
	
	    if(count($_POST[$item04]) != 0)	
	      {
	         for($i = 0; $i < sizeof($_POST[$item04]); $i++)
	            {
			if($i > 0) echo ', ';
			echo $_POST[$item04][$i];

			$champ = $_POST[$item04][$i];

			if($i<count($_POST[$item04])-1)
		  	  {$chaine04 = $chaine04 ."'$champ'" .", ";
		  	  }
			if($i == count($_POST[$item04])-1)
		     	  {$chaine04 = $chaine04 ."'$champ'";
			  }  
	           }
		 echo "++++++++ " .$chaine04;
		
	         $final04 = $champs_filtre[3] ." IN (" .$chaine04 .")";
	         $portion_sql[] = $champs_filtre[3] ." IN (" .$chaine04 .")";
             }

          }    
          
	echo '<br /><br />';

	if(count($critere05) != 0)
	  {
	    echo '<b>- '.$item05.' :</b> ';
	    $chaine05 ="";
	
	    if(count($_POST[$item05]) != 0)	
	      {
	         for($i = 0; $i < sizeof($_POST[$item05]); $i++)
	            {
			if($i > 0) echo ', ';
			echo $_POST[$item05][$i];
		
			$champ = $_POST[$item05][$i];

			if($i<count($_POST[$item05])-1)
		  	  {$chaine05 = $chaine05 ."'$champ'" .", ";
		  	  }
			if($i == count($_POST[$item05])-1)
		     	  {$chaine05 = $chaine05 ."'$champ'";
			  }  
	            }
	          echo "++++++++ " .$chaine05;
	       
       	          $final05 = $champs_filtre[4] ." IN (" .$chaine05 .")";
	          $portion_sql[] = $champs_filtre[4] ." IN (" .$chaine05 .")";
	     }	

          }  
          
	echo '<br /><br />';
         
        if(count($critere06) != 0)
	  {
	    echo '<b>- '.$item06.' :</b> ';
	    $chaine06 ="";
	
	    if(count($_POST[$item06]) != 0)	
	      {	
	
	         for($i = 0; $i < sizeof($_POST[$item06]); $i++)
	            {
			if($i > 0) echo ', ';
			echo $_POST[$item06][$i];
		
			$champ = $_POST[$item06][$i];

			if($i<count($_POST[$item06])-1)
		  	  {$chaine06 = $chaine06 ."'$champ'" .", ";
		  	  }
			if($i == count($_POST[$item06])-1)
		     	  {$chaine06 = $chaine06 ."'$champ'";
			  }  
	            }
	         echo "++++++++ " .$chaine06;
	       
	         $final06 = $champs_filtre[5] ." IN (" .$chaine06 .")";
	         $portion_sql[] = $champs_filtre[5] ." IN (" .$chaine06 .")";
              }

          }    
          
	echo '<br /><br />';
	
	echo "<br>"; 
	echo "<pre>"; 
	var_dump($portion_sql);
	echo "</pre>";
        echo "<br>"; 
        
         // construire le requete
	    
	    $portion ="";
	    $chaine = "";
	    
	    for($k=0; $k<=count($portion_sql)-1; $k++) 
  	       { 
  	       	 	$champ = $portion_sql[$k];
  	       		
  	       		if(champ !="")
  	       		  {
  	       	  		if($k<count($portion_sql)-1)
		    		  {$chaine = $chaine .$portion_sql[$k] ." and ";
	            		  }
	          		if($k == count($portion_sql)-1)
		    		  {$chaine = $chaine .$portion_sql[$k];
	            		  }  
	       		  }
	       }		  
	       
	       $flag = "filtre";
	       
	       
	       if($chaine == "")
	         {  $req = " SELECT * FROM $table ";
	         }	
	       else {
	             $req = " SELECT * FROM $table WHERE " .$chaine;
		     echo $req;
		}
		
		
		$connexion = mysql_connect($db_host,$db_user,$db_pass); 
       	    	mysql_select_db($db_name, $connexion);
	    
	    	//$requete = " SELECT * FROM cruchot WHERE chargement = 'Hublot' or chargement = '2' ";
	    	$result = mysql_query($req);
	    
	    	echo "<br>"; 
	    	echo "Nb de resultat:" .mysql_num_rows($result); 
	    	echo "<br>"; 
	    
	    	$nb_resultats_filtre = mysql_num_rows($result);
    	
	    	if($nb_resultats_filtre != 0)
	          { 	    	
    	    	   while($datas = mysql_fetch_assoc($result))
                        {
                          echo $datas['reference'];
                          echo "<br>"; 
                        }
                  }
          	else { echo "Aucune réponse";} 
	    
	    	echo "<br>"; 
	    	echo "<br>"; 
     	
     	
		
	
}


			/*********************************/

/**
* permet de créer le pseudo-composant
* @param :
* - nom : le nom du composant
* - structure : les colonnes, les dimensions, les alignements (tableau)
* - contenu : les elements : valeur checkbox + autres colonnes (tableau)
* - selection : tableau de valeur a selectionner (correspond a la valeur de la checkbox)
*/
function checkedSelect( $nom, $structure, $contenu, $selection = null) {

//////////////// entete du composant \\\\\\\\\\\\\\\\\\\\\\\\\
if(sizeof($selection) == sizeof($contenu))
$checked = "checked";
else
$checked = "";


$str = '<div class="div_select">'
.'<div class="div_select_header">'
.'<table width="100%">'
.'<tr>'
.'<td width="20" align="center"><input type="checkbox" id="'.$nom.'" onClick="javascript:selectAll(this, '.sizeof($contenu).');" '.$checked.'/></td>';

//--- colonnes
for($i = 0, $max = sizeof($structure); $i < $max; $i++) {
$str .= '<td ';
if(isset($structure[$i]["align"])) $str .= 'align="'.$structure[$i]["align"].'" ';
if(isset($structure[$i]["width"])) $str .= 'width="'.$structure[$i]["width"].'" ';
$str .= '>'.$structure[$i]["name"].'</td>';
}

$str .= '<td width="1"></td>'
.'</tr>'
.'</table>'
.'</div>';

//////////////// contenu du composant \\\\\\\\\\\\\\\\\\\\\\\\\
$str .= '<div class="div_select_content" >'
.'<table width="100%">';

//--- pour chaque ligne
for($i = 0, $max = sizeof($contenu); $i < $max; $i++) {

//--- style css (pair / impair)
if($i%2)
$css_defaut = 'select_odd';
else
$css_defaut = 'select_even';

//--- element selectionne ?
if($selection != null && in_array($contenu[$i][0],$selection)) {
$checked = ' checked';
$css = 'select_checked';
}
else {
$checked = '';
$css = $css_defaut;
}

//--- la checkbox
$str .= '<tr id="tr_'.$nom.$i.'" class="'.$css.'" onMouseOver=\'javascript:setEvenement("'.$nom.'","'.$i.'","over","'.$css.'",'.sizeof($contenu).',"td");\' onMouseOut=\'javascript:setEvenement("'.$nom.'","'.$i.'","out","'.$css_defaut.'",'.sizeof($contenu).',"td");\' '
.' onClick=\'javascript:setEvenement("'.$nom.'","'.$i.'","click", "'.$css_defaut.'",'.sizeof($contenu).',"td");\' >'
.'<td width="20" ><input type="checkbox" id="'.$nom.$i.'" name="'.$nom.'[]" value="'.$contenu[$i][0].'" onClick=\'javascript:setEvenement("'.$nom.'","'.$i.'","click","'.$css_defaut.'",'.sizeof($contenu).',"ck");\' '.$checked.' /></td>';

//--- les colonnes
for($j = 1; $j < sizeof($contenu[$i]); $j++) {
$str .= '<td ';
if(isset($structure[$j-1]["align"])) $str .= 'align="'.$structure[$j-1]["align"].'" ';
if(isset($structure[$j-1]["width"])) $str .= 'width="'.$structure[$j-1]["width"].'" ';
$str .= '>'.$contenu[$i][$j].'</td>';
}

$str .= '</tr>';
}

//--- fermeture des balises
$str .= '</table>'
.'</div>'
.'</div>';

return $str;
}


//===============================================================
// VARIABLES D'EXEMPLES
//===============================================================
$nom1 = "test1";

$structure1 = array (
array("name" => "Marque", "align" => "center", "width" => "40px")
);


$contenu1 = array (
array("Bosh", "Bosh"),
array("Brandt", "Brandt"),
array("Indesit", "Indesit"),
array("Laden", "Laden"),
array("LG", "LG"),
array("Siemens", "Siemens"),
array("Whirlpool", "Whirlpool")
);

	//var_dump($contenu);

$aaa2 = "test2";

$aastructure2 = array (
array("name" => "CODE", "align" => "center", "width" => "40px")
);

$aacontenu2 = array (
array("Brandt", "Brandt"),
array("Bosh", "Bosh ")
);


/*$aacontenu2 = array (
array("001", "TEST €"),
array("002", "TEST "),
array("003", "TEST €"),
array("004", "TEST €"),
array("005", "TEST "),
array("006", "TEST "),
array("007", "TEST €") ,
array("005", "TEST 4 €")
);*/

//======================================================
// VERFICATION DU POST
//======================================================
/*if($_POST["submit"])
  {
     echo '<b>Formulaire validé avec les éléments : </b><br>';

	echo '<b>- '.$item01.' :</b> ';
	
	for($i = 0; $i < sizeof($_POST[$item01]); $i++)
	   {
		if($i > 0) echo ', ';
		echo $_POST[$item01][$i];
	   }

	echo '<br /><b>- '.$nom2.' :</b> ';
	
	for($i = 0; $i < sizeof($_POST[$nom2]); $i++) 
	{
		if($i > 0) echo ', ';
		echo $_POST[$nom2][$i];
	}

	echo '<br /><br />';
}*/

?>


<?php

	$connexion = mysql_connect($db_host,$db_user,$db_pass); 
       	mysql_select_db($db_name, $connexion);
  
  	$table = "washer"; 
  
  	$requete = "SELECT filtre FROM categorie WHERE table_article='$table'";	

    	$result = mysql_query($requete);
    	$datas = mysql_fetch_array($result);
    	    	
    	// decoupe la chaine
    	$champs_filtre = explode(",", $datas[0]);
    	
    	var_dump($champs_filtre);
    	
    	
    	// declaration tableau à 2 dimensions
    	$tab2dim = array(array()) ;
	
	for($i=0; $i<=count($champs_filtre)-1; $i++) 
	    {   		
			    	$index = $champs_filtre[$i];
    				//echo $index;
    	
    				$connexion = mysql_connect($db_host,$db_user,$db_pass); 
       				mysql_select_db($db_name, $connexion);
    				$sql = "SELECT $index FROM $table "; 
    				//echo $sql;
    				$result = mysql_query($sql);
  	
  				// déclarer un tableau vide
  				$tab = array();
  	
  				while($data=mysql_fetch_row($result))  
             			{
             	   			if(in_array($data[0], $tab))
             	    			  { // existe
             	    				$nada = True;
		    			  }   
		    		     else { // nouveau : on le stocke
		    	   		    $tab[] = $data[0];
		    	                  }
			    		  // echo $data[0];
    		  			  // echo "<br>"; 
	    		
	     			}
        			// sauve dans le tableau multidimensionnel
        			$tab2dim[] = $tab;
        			 
         			//echo count($tab); 
    	    			// print_r($tab);
			   	// echo "<br>"; 
			   	 
		}	   	 

	
     	
    	
?>

<?php
	 
		$pipo = array(array()) ;
	
/*	$contenu = array (
array("AD", "TEST AD"),
array("CC", "TEST CC"),
array("DZ", "TEST DZ"),
array("GV", "TEST GV"),
array("LS", "TEST LS"),
array("LC", "TEST LC"),
array("SG", "TEST SG")
);*/
	
	 
         // attention le double tableau commence en 1 et pas en 0
	 for($i=1; $i<=count($champs_filtre); $i++) 
	    {   $taille = count($tab2dim[$i]);
	    	for($j=0; $j<$taille; $j++) 	
	 	   { $nom =  $tab2dim[$i][$j];
	    	     $val_ligne = $champs_filtre[$i-1] .$j;
       		     
       		     if(in_array($val_ligne, $_SESSION['checkbox'] ))
          	       { $nada = True;
       		       }
       		     else { array_push($_SESSION['checkbox'],$val_ligne);
       	   	          }
			  
                               for($k=0; $k <count($_POST['choix']); $k++) 	
  				   {                           	
                             	      if($val_ligne == $_POST['choix'][$k])
                                        { $flag = true;
                                          //echo "ok";
                                          //echo "<br>"; 
                                          break;
	                                }	
                                   else { $flag = false; } 	
                                  }
			     
       		     
       		     if($flag == true)
       		       {  echo " <input type=\"checkbox\" name=\"choix[]\" checked=\"checked\" value=\"$val_ligne\" >$nom";
       		       }
       		     if($flag == false)
       		       {  echo " <input type=\"checkbox\" name=\"choix[]\" value=\"$val_ligne\" >$nom";
       		       }         		       
       		       echo $val_ligne .$nom;
       		       

     		           		//   $contenu[] = array($nom, $val_ligne);

       		       
    		   }
    		   echo "<br>"; 
    		   
    		   //$contenu = array($nom,$val_ligne);  
    		   
    		   
    		   
	   } 	
	   	   var_dump($pipo);
?>

	 <input type = 'submit' name = "soumettre" value ='Filtre'>
	 </form> 

<?php


	$flag == false;

	$critere01 = array(array());  
	$critere02 = array(array());  
	$critere03 = array(array());  
	$critere04 = array(array());  
	$critere05 = array(array());  
	$critere06 = array(array());  
	$critere07 = array(array());  
	$critere08 = array(array());  
	$critere09 = array(array());  
	$critere10 = array(array());  
	
	$item01 = "item01";
	$struct01 = array ( array("name" => "$champs_filtre[0]", "align" => "center", "width" => "40px"));
	
	$item02 = "item02";
	$struct02 = array ( array("name" => "$champs_filtre[1]", "align" => "center", "width" => "40px"));
	
	$item03 = "item03";
	$struct03 = array ( array("name" => "vitesse", "align" => "center", "width" => "40px"));
	
	$item04 = "item04";
	$struct04 = array ( array("name" => "$champs_filtre[3]", "align" => "center", "width" => "40px"));
	
	$item05 = "item05";
	$struct05 = array ( array("name" => "$champs_filtre[4]", "align" => "center", "width" => "40px"));
	
	$item06 = "item06";
	$struct06 = array ( array("name" => "$champs_filtre[5]", "align" => "center", "width" => "40px"));
	
	
	
	
	for($i=0; $i<count($champs_filtre); $i++) 
	   { 
		$connexion = mysql_connect($db_host,$db_user,$db_pass); 
       		mysql_select_db($db_name, $connexion);
  
  		$critere = $champs_filtre[$i];
  			
  		$requete = "SELECT $critere FROM $table";	
    		$result = mysql_query($requete);
    			
    		$p = 0;
    		$tempo = array();
    		
    		if($i == 0)
    		  { $tab = "critere01";
    		    $cpt = 0;
    		    while($data=mysql_fetch_row($result))  
             		{ 	if($cpt == 0)
             			  { $tempo[] = $data[0];
             			    $critere01[$p][0] = $data[0];
  				    $critere01[$p][1] = $data[0];
             	   		    $p = $p+1;
             			  } 
             			if($cpt > 0)
             			  {    $var = $data[0];
             			       if(in_array($var, $tempo))
             			         { $test = false;
				         }
             	   		    else {  $tempo[] = $var;
             	   			    $critere01[$p][0] = $data[0];
  					    $critere01[$p][1] = $data[0];
             	   			    $p = $p+1;
             	   		          }
             	   		   }  
             	   		     $cpt = $cpt +1;   	
		    	}
    		  }	
		if($i == 1)
    		  { $tab = "critere02";
    		    $cpt = 0;
    		    while($data=mysql_fetch_row($result))  
             		{	if($cpt == 0)
             			  { $tempo[] = $data[0];
             			    $critere02[$p][0] = $data[0];
  				    $critere02[$p][1] = $data[0];
             	   		    $p = $p+1;
             			  } 
             			if($cpt > 0)  
             			  {    $var = $data[0];
             			       if(in_array($var, $tempo))
             			         { $test = false;
				         }
             	   		    else {  $tempo[] = $var;  
             			            $critere02[$p][0] = $data[0];
  				            $critere02[$p][1] = $data[0];
             	   		            $p = $p+1;
			    	         }
			    	  }  
             	   		     $cpt = $cpt +1;   	
                      }
    		  }	
    		if($i == 2)
    		  { $tab = "critere03";
    		    $cpt = 0;
    		    while($data=mysql_fetch_row($result))  
             		{	if($cpt == 0)
             			  { $tempo[] = $data[0];
             			    $critere03[$p][0] = $data[0];
  				    $critere03[$p][1] = $data[0];
  				    $p = $p+1;
             			  } 
             			if($cpt > 0)
             			 {     $var = $data[0];
             			       if(in_array($var, $tempo))
             			         { $test = false;
				         }
				        else {  $tempo[] = $var;  
             	   				$critere03[$p][0] = $data[0];
  						$critere03[$p][1] = $data[0];
             	   				$p = $p+1;
             	   			     }
             	   		 }	      	
             	   		    $cpt = $cpt +1;   	
		    	}
    		  }	
    		if($i == 3)
    		  { $tab = "critere04";
    		    $cpt = 0;
		    while($data=mysql_fetch_row($result))  
             		{       if($cpt == 0)
             			  { $tempo[] = $data[0];
             			    $critere04[$p][0] = $data[0];
 	                            $critere04[$p][1] = $data[0];
             	   		    $p = $p+1;
             			  } 
             			if($cpt > 0)
             			 {     $var = $data[0];
             			       if(in_array($var, $tempo))
             			         { $test = false;
				         }
				       else {  $tempo[] = $var;  
             	   			       $critere04[$p][0] = $data[0];
  					       $critere04[$p][1] = $data[0];
             	   		               $p = $p+1;
             	   		            }
             	   		  }	      	
             	   		     $cpt = $cpt +1;        
		    	}	
    		  }	
    		if($i == 4)
    		  { $tab = "critere05";
    		    $cpt = 0;
		    while($data=mysql_fetch_row($result))  
             		{	if($cpt == 0)
             			  { $tempo[] = $data[0];
             			    $critere05[$p][0] = $data[0];
  				    $critere05[$p][1] = $data[0];
             	   		    $p = $p+1;
             			  } 
             			if($cpt > 0)
             			 {     $var = $data[0];
             			       if(in_array($var, $tempo))
             			         { $test = false;
				         }
				        else {  $tempo[] = $var;  
             	   				$critere05[$p][0] = $data[0];
  						$critere05[$p][1] = $data[0];
             	   				$p = $p+1;
		    		             }
				 }	      	
             	   		      $cpt = $cpt +1;		    		             	
		        }
    		  }	      
		if($i == 5)
    		  { $tab = "critere06";
    		    $cpt = 0;
		    while($data=mysql_fetch_row($result))  
             		{	if($cpt == 0)
             			  { $tempo[] = $data[0];
             			    $critere06[$p][0] = $data[0];
   		                    $critere06[$p][1] = $data[0];
             	   		    $p = $p+1;
             			  } 
             			if($cpt > 0)
             			 {     $var = $data[0];
             			       if(in_array($var, $tempo))
             			         { $test = false;
				         }
				        else {  $tempo[] = $var;  
             	   				$critere06[$p][0] = $data[0];
  						$critere06[$p][1] = $data[0];
             	   				$p = $p+1;
             	   			     }
		    	           }
             	   		      $cpt = $cpt +1;
    		        }	
	          }
	      
	     }     


	

	$debug = false;

	if($debug == true)
          {
	     echo "****************** Affichage pour le debug **************************"; 
    			echo "<br>"; 
			echo "<pre>"; 
			print_r($critere01);
			echo "</pre>";
             		echo "<br>"; 
             		
             		
             		echo "<br>"; 
			echo "<pre>"; 
			print_r($aacontenu2);
			echo "</pre>";
             		echo "<br>"; 
             		
    			
    			echo "<br>"; 
			echo "<pre>"; 
			print_r($critere02);
			echo "</pre>";
             		echo "<br>"; 
             		
             		echo "<br>"; 
			echo "<pre>"; 
			print_r($critere03);
			echo "</pre>";
             		echo "<br>"; 

			echo "<br>"; 
			echo "<pre>"; 
			print_r($critere04);
			echo "</pre>";
             		echo "<br>"; 

			echo "<br>"; 
			echo "<pre>"; 
			print_r($critere05);
			echo "</pre>";
             		echo "<br>"; 
             		
             		echo "<br>"; 
			echo "<pre>"; 
			print_r($critere06);
			echo "</pre>";
             		echo "<br>"; 

	  }

//======================================================
// VERFICATION DU POST
//======================================================
/*if($_POST["submit"])
  {
	header('Location: aargrggrafraichir_filtre.php');
  	
  	
  	
        echo '<b>Formulaire validé avec les éléments : </b><br>';
	
        $portion_sql = array();
	
	if(count($critere01) != 0)
	  {
	    echo '<b>- '.$item01.' :</b> ';
	    $chaine01 ="";	
	
	    if(count($_POST[$item01]) != 0)	
	      {
    		  for($i = 0; $i < sizeof($_POST[$item01]); $i++)
	             {
			if($i > 0) echo ', ';
			echo $_POST[$item01][$i];

			$champ = $_POST[$item01][$i];

			if($i<count($_POST[$item01])-1)
		  	  {$chaine01 = $chaine01 ."'$champ'" .", ";
		  	  }
			if($i == count($_POST[$item01])-1)
		     	  {$chaine01 = $chaine01 ."'$champ'";
			  }  
	            }
		  echo "++++++++ " .$chaine01;
		
		  $final01 = $champs_filtre[0] ." IN (" .$chaine01 .")";
	    	  $portion_sql[] = $champs_filtre[0] ." IN (" .$chaine01 .")";
	    }	

	 }      
         
	echo '<br /><br />';
          
        if(count($critere02) != 0)
	  {
	    echo '<b>- '.$item02.' :</b> ';
	    $chaine02 ="";
	
	    if(count($_POST[$item02]) != 0)	
	      {	
	    	 for($i = 0; $i < sizeof($_POST[$item02]); $i++)
	            {
			if($i > 0) echo ', ';
			echo $_POST[$item02][$i];
			
			$champ = $_POST[$item02][$i];

			if($i<count($_POST[$item02])-1)
		  	  {$chaine02 = $chaine02 ."'$champ'" .", ";
		  	  }
			if($i == count($_POST[$item02])-1)
		     	  {$chaine02 = $chaine02 ."'$champ'";
			  }  
	            }
	         echo "++++++++ " .$chaine02;
	       
	         $final02 = $champs_filtre[1] ." IN (" .$chaine02 .")";
	         $portion_sql[] = $champs_filtre[1] ." IN (" .$chaine02 .")";
             }

          }  
	
	echo '<br /><br />';

	if(count($critere03) != 0)
	  {
	    echo '<b>- '.$item03.' :</b> ';
	    $chaine03 ="";	
	
	    if(count($_POST[$item03]) != 0)	
	      {
		 for($i = 0; $i < sizeof($_POST[$item03]); $i++)
	            {
			if($i > 0) echo ', ';
			echo $_POST[$item03][$i];
			
			$champ = $_POST[$item03][$i];

			if($i<count($_POST[$item03])-1)
		  	  {$chaine03 = $chaine03 ."'$champ'" .", ";
		  	  }
			if($i == count($_POST[$item03])-1)
		     	  {$chaine03 = $chaine03 ."'$champ'";
			  }  
	            }
		 echo "++++++++ " .$chaine03;
		
	         $final03 = $champs_filtre[2] ." IN (" .$chaine03 .")";
	         $portion_sql[] = $champs_filtre[2] ." IN (" .$chaine03 .")";
	     }	

          }  
	echo '<br /><br />';
          
        if(count($critere04) != 0)
	  {
	    echo '<b>- '.$item04.' :</b> ';
	    $chaine04 ="";
	
	    if(count($_POST[$item04]) != 0)	
	      {
	         for($i = 0; $i < sizeof($_POST[$item04]); $i++)
	            {
			if($i > 0) echo ', ';
			echo $_POST[$item04][$i];

			$champ = $_POST[$item04][$i];

			if($i<count($_POST[$item04])-1)
		  	  {$chaine04 = $chaine04 ."'$champ'" .", ";
		  	  }
			if($i == count($_POST[$item04])-1)
		     	  {$chaine04 = $chaine04 ."'$champ'";
			  }  
	           }
		 echo "++++++++ " .$chaine04;
		
	         $final04 = $champs_filtre[3] ." IN (" .$chaine04 .")";
	         $portion_sql[] = $champs_filtre[3] ." IN (" .$chaine04 .")";
             }

          }    
          
	echo '<br /><br />';

	if(count($critere05) != 0)
	  {
	    echo '<b>- '.$item05.' :</b> ';
	    $chaine05 ="";
	
	    if(count($_POST[$item05]) != 0)	
	      {
	         for($i = 0; $i < sizeof($_POST[$item05]); $i++)
	            {
			if($i > 0) echo ', ';
			echo $_POST[$item05][$i];
		
			$champ = $_POST[$item05][$i];

			if($i<count($_POST[$item05])-1)
		  	  {$chaine05 = $chaine05 ."'$champ'" .", ";
		  	  }
			if($i == count($_POST[$item05])-1)
		     	  {$chaine05 = $chaine05 ."'$champ'";
			  }  
	            }
	          echo "++++++++ " .$chaine05;
	       
       	          $final05 = $champs_filtre[4] ." IN (" .$chaine05 .")";
	          $portion_sql[] = $champs_filtre[4] ." IN (" .$chaine05 .")";
	     }	

          }  
          
	echo '<br /><br />';
         
        if(count($critere06) != 0)
	  {
	    echo '<b>- '.$item06.' :</b> ';
	    $chaine06 ="";
	
	    if(count($_POST[$item06]) != 0)	
	      {	
	
	         for($i = 0; $i < sizeof($_POST[$item06]); $i++)
	            {
			if($i > 0) echo ', ';
			echo $_POST[$item06][$i];
		
			$champ = $_POST[$item06][$i];

			if($i<count($_POST[$item06])-1)
		  	  {$chaine06 = $chaine06 ."'$champ'" .", ";
		  	  }
			if($i == count($_POST[$item06])-1)
		     	  {$chaine06 = $chaine06 ."'$champ'";
			  }  
	            }
	         echo "++++++++ " .$chaine06;
	       
	         $final06 = $champs_filtre[5] ." IN (" .$chaine06 .")";
	         $portion_sql[] = $champs_filtre[5] ." IN (" .$chaine06 .")";
              }

          }    
          
	echo '<br /><br />';
	
	echo "<br>"; 
	echo "<pre>"; 
	var_dump($portion_sql);
	echo "</pre>";
        echo "<br>"; 
        
         // construire le requete
	    
	    $portion ="";
	    $chaine = "";
	    
	    for($k=0; $k<=count($portion_sql)-1; $k++) 
  	       { 
  	       	 	$champ = $portion_sql[$k];
  	       		
  	       		if(champ !="")
  	       		  {
  	       	  		if($k<count($portion_sql)-1)
		    		  {$chaine = $chaine .$portion_sql[$k] ." and ";
	            		  }
	          		if($k == count($portion_sql)-1)
		    		  {$chaine = $chaine .$portion_sql[$k];
	            		  }  
	       		  }
	       }		  
	       
	       $flag = "filtre";
	       
	       
	       if($chaine == "")
	         {  $req = " SELECT * FROM $table ";
	         }	
	       else {
	             $req = " SELECT * FROM $table WHERE " .$chaine;
		     echo $req;
		}
		
		
		$connexion = mysql_connect($db_host,$db_user,$db_pass); 
       	    	mysql_select_db($db_name, $connexion);
	    
	    	//$requete = " SELECT * FROM cruchot WHERE chargement = 'Hublot' or chargement = '2' ";
	    	$result = mysql_query($req);
	    
	    	echo "<br>"; 
	    	echo "Nb de resultat:" .mysql_num_rows($result); 
	    	echo "<br>"; 
	    
	    	$nb_resultats_filtre = mysql_num_rows($result);
    	
	    	if($nb_resultats_filtre != 0)
	          { 	    	
    	    	   while($datas = mysql_fetch_assoc($result))
                        {
                          echo $datas['reference'];
                          echo "<br>"; 
                        }
                  }
          	else { echo "Aucune réponse";} 
	    
	    	echo "<br>"; 
	    	echo "<br>"; 
     	
     	
		
	
}
*/

			/*********************************/


  	//eval('$tableau = array(1=>"bleu", 4, 10);'); 
  	
  	//$blase = $champs_filtre[0];
  	//eval('$blase = array(array()); ');
  	
  	
  	//$blase[0][0] = "cretin";
  	//$blase[0][1] = "pustule";
  	 
  	//eval('$champs_filtre[1] = array(1=>"deux", bbb, sd);'); 
  	
	//print_r($blase);
	//echo "<br>"; 
	//print_r($champs_filtre[1]);
		
	/*	 for($i=0; $i<count($champs_filtre); $i++) 
		    { 
			$connexion = mysql_connect($db_host,$db_user,$db_pass); 
       			mysql_select_db($db_name, $connexion);
  
  			$blase = $champs_filtre[$i];
  			$critere = $champs_filtre[$i];
  			eval(' $blase = array(array()); '); 
  			
  			$requete = "SELECT $critere FROM $table";	
    			$result = mysql_query($requete);
    			
    			$p = 0;
    			
    			while($data=mysql_fetch_row($result))  
             		{
             	   		//echo $data[0];
             	   		//$nom[] = $data[0];
             	   		//$nom[] = $data[0];
             	   		$blase[$p][0] = $data[0];
  				$blase[$p][1] = $data[0];
             	   		
             	   		//$nom_tab[$p][0] = $data[0]; 
             	   		//$nom_tab[$p][1] = $data[0]; 
             	   		$p = $p+1;
		    	}

			echo "<br>"; 
			echo "<pre>"; 
			var_dump($blase);
			echo "</pre>";
             		echo "<br>"; 
	     }
    			
    			
    			$tab = $champs_filtre[2];
    			echo $tab;
    			$test = is_array($tab);
    			echo "************** " .$test;
    			
    			
			
//Dynamically name array <input>    			
             		
    			echo "********************************************"; 
    			echo "<br>"; 
			echo "<pre>"; 
			//eval(' var_dump($champs_filtre[2]); '); 
			$var = "chargement";
			print_r(${$var});
			echo "</pre>";
             		echo "<br>"; 
    			
    			
    			/*echo "<br>"; 
    			echo "<br>"; 
    			print_r($contenu1);
    			
    			
    			echo "<br>"; 
    			echo "<br>"; 
    			
    			print_r($nom_ens0);
    			
    			echo "<br>"; 
    			echo "<br>"; */
    			
    			
    			
    			/*$liste_tab = array();
    			$liste_tab[] = "marque";
    			$liste_tab[] = "prix";
    			
    			$v = ."0";
    			$v= $liste_tab[0];
    			$v= array();
    			
    			$n[] = "dick";
    			$n[] = "le gars ";
    			$n[] = "2010";
    			$n[] = "pifou";*/
    			
    			//print_r($n);
    			
    			
    			/*$bbb = "tableau_1";
    			$bbb = array();
    			
    			$bbb[] = "br";
    			$bbb[] = "ergt ";
    			$bbb[] = "gloop";
    			$bbb[] = "rien";
    			
    			
    			print_r($aaa);
    			echo "<br>"; 
    			print_r($bbb);
    			
    			
    			
    			
    			
    			
/*$contenu1 = array (
array("Bosh", "Bosh"),
array("Brandt", "Brandt"),
array("Indesit", "Indesit"),
array("Laden", "Laden"),
array("LG", "LG"),
array("Siemens", "Siemens"),
array("Whirlpool", "Whirlpool")
);    			*/
    			
    			
/*	$Discotheque = array(array()) ;
	
	$Discotheque[0][0] = "Bosh" ;
	$Discotheque[0][1] = "Bosh" ;
	
	$Discotheque[1][0] = "Brandt" ;
	$Discotheque[1][1] = "Bach" ;
	
	$Discotheque[2][0] = "Indesit" ;
	$Discotheque[2][1] = "Indesit" ;
	
	$Discotheque[3][0] = "Laden" ;
	$Discotheque[3][1] = "Laden" ;
	
	$Discotheque[4][0] = "LG" ;
	$Discotheque[4][1] = "LG" ;     
	
	$Discotheque[5][0] = "Siemens" ;
	$Discotheque[5][1] = "Siemens" ;     
	
	$Discotheque[6][0] = "Whirlpool" ;
	$Discotheque[6][1] = "Whirlpool" ;     
				
	echo "<br>"; 
    	echo "<br>"; 
    	print_r($Discotheque);*/
    			
				
    			
    			
	/*echo "<br>"; 
	echo "<br>"; 
	echo "<br>"; 
	
	$nom = $blase ."0";
	
	$nom = array();
	$nom[] = 747; 
	$nom[] = "bod"; 
	$nom[] = 123.45; 
	$nom[] = "rien"; */
	
	

	
	//var_dump($nom);
	//echo "<br>"; 
	
	/*$nom = $tab ."1";
	var_dump($nom);
	echo "<br>"; 
	
	$nom = $tab ."2";
	var_dump($nom);
	echo "<br>"; 

	$nom = $tab ."3";
	var_dump($nom);
	echo "<br>"; 

	$nom = $tab ."4";	
	var_dump($nom);
	echo "<br>"; 
	
	$nom = $tab ."5";
	var_dump($nom);
	echo "<br>"; */
	
	
	//echo "<br>";
	//echo "<br>";

// Déclaration des différents array()
/*$pizzas = array('royale','vegetarienne');
$fruits = array('fraise','orange');

$variable = 'pizzas';

for ($i=0; $i < count(${$variable}); $i++) {
echo ${$variable}[$i].'<br/>';*/
//}

	  
		  

?>




<script language="javascript" type="text/javascript">

/**
* selectionne l'ensemble des elements d'une liste déroulante avec checkbox
* @param :
* - obj : le nom du pseudo-composant
* - nb : nombre d'elements que contient le composant
*/
function selectAll(obj, nb) {
for (i=0; i< nb; i++) {
document.getElementById(obj.id + i).checked = obj.checked;

if(obj.checked)
document.getElementById("tr_"+obj.id+i).className = "select_checked";
else {
if(i % 2)
css = "select_odd"
else
css ="select_even";

document.getElementById("tr_"+obj.id+i).className = css;
}
}
}

/**
* selectionne l'ensemble des elements d'une liste déroulante avec checkbox
* @param :
* - obj : le nom du pseudo-composant
* - el_id : id de l'element (position dans le composant)
* - ev : le type d'evenement
* - css_defaut : le style de la ligne par defaut
* - nb : le nombre d'elements
*/
function setEvenement(obj, el_id, ev, css_defaut, nb, provenance) {

//--- recuperation des balises
comp = document.getElementById(obj);
tr = document.getElementById("tr_" + obj + el_id);
ck = document.getElementById(obj + el_id);

//--- si il s'agit d'un clique
if(ev == "click") {
//--- alors on coche ou decoche la checkbox
if(provenance = "td") ck.checked = !ck.checked;


//--- si on decoche, alors on decoche aussi la checkbox du composant
if(!ck.checked) {
if(comp.checked) comp.checked = false;
}
else {

//---sinon on vérifie que tous les elements sont cochés
var absent = false;
var i = 0;

while(i < nb && absent == false) {
if(i != el_id) {
if(!document.getElementById(obj + i).checked) absent = true;
}
i++;
}

if(comp.checked == absent) comp.checked = !absent;
}
}

//--- autres evenements
switch(ev) {
case "over":
tr.className = "select_over";
break;

case "out":
if(ck.checked)
tr.className = "select_checked";
else
tr.className = css_defaut;
break;
}
}

</script>
</head>
<body>	