<?php

	 session_start();
	 
	 $_SESSION['database']="local";
	 
	 if($_SESSION['database']=="local")
	  {
	     $db_host    = "localhost";
	     $db_user   = "root";
	     $db_pass   = "";
     	     $db_name   = "boutique";

	 }
	
	if($_SESSION['database']=="public")
	  {
  	     $db_host    = "sql2";
   	     $db_user   = "analogde";
 	     $db_pass   = "rainbow";
    	     //$db_type   = "mysql";
	     $db_name   = "analogde";
	 }

	
	 // lave_linge
	 $ch1 ="Marque";
	 $ch2 ="Modele";
	 $ch3 ="Chargement";
	 $ch4 ="Capacite en Kg";	
	 $ch5 ="Classe énergétique";	
	 $ch6 ="Classe d'efficacité de lavage";
	 $ch7 ="Classe d'efficacité de l'essorage";
	 $ch8 ="Vitesse d'essorage trs-min";
	 $ch9 ="Consommation d'énergie KWh-cycle";
	 $ch10 ="Consommation d'eau en l par cycle";
	 $ch11 = "Prix";

	 $trame = $ch1 ."," .$ch2 ."," .$ch3 ."," .$ch4 ."," .$ch5 ."," .$ch6 ."," .$ch7 ."," .$ch8 ."," .$ch9 ."," .$ch10 ."," .$ch11 ;  
	 $trame = addslashes($trame);

	 // lave_vaisselle
	 $ch1 ="Marque";
	 $ch2 ="Modele";
	 $ch3 ="Nombre de couverts";
	 $ch4 ="Niveau sonore en décibels";	
	 $ch5 ="Classe énergétique";	
	 $ch6 ="Classe d'efficacité de lavage";
	 $ch7 ="Classe d'efficacité de l'essorage";
	 $ch8 ="Consommation d'eau en l par cycle";
	 $ch9 ="Type de pose";
	 $ch10 ="Départ différé";
	 $ch11 = "Prix";

	 $trame = $ch1 ."," .$ch2 ."," .$ch3 ."," .$ch4 ."," .$ch5 ."," .$ch6 ."," .$ch7 ."," .$ch8 ."," .$ch9 ."," .$ch10 ."," .$ch11 ;  
	 $trame = addslashes($trame);


	 // refrigerateur
	 
	 
	 
	 // congelateur

	 
	 $connexion = mysql_connect($db_host,$db_user,$db_pass); 
	 mysql_select_db($db_name, $connexion);
	 
	 
	 /* interroger */
	 
	 //$element = "KU78-8";
	 //$requete = "SELECT * FROM lave_linge WHERE modele='$element' ";
       	 //$result = mysql_query($requete);
	 //$data = mysql_fetch_array($result);
	 //echo $data['descriptif'];
	
	 //$element = "3";
	 //$requete = "SELECT * FROM categorie WHERE id='$element' ";
       	 //$result = mysql_query($requete);
	 //$data = mysql_fetch_array($result);
	 //echo $data['table'];


	 //$element = "lave_linge";
	 //$requete = "SELECT * FROM essai WHERE table_article='$element' ";
       	 //$result = mysql_query($requete);
	 //$data = mysql_fetch_array($result);
	 //echo $data['id'];

	 
	
	
	 /*  inserer */
	 $element = "lave_vaisselle" ;
	 /* mise à jour */
	 $requete = "UPDATE categorie SET filtre = '$trame'  WHERE table_article = '$element' ";
 	 $result = mysql_query($requete);
	 
	
	 
	 // pour le debug
	 $sql = "SELECT * FROM categorie WHERE table_article = '$element' ";
 	 $requete = mysql_query( $sql, $connexion ) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 
	 $result = mysql_fetch_assoc($requete);
	 echo($result['filtre']) ;

?>
	