<?php

session_start();

	
	 
        		$indice = 32;
        		
        		
			//header("Location: dev_panfffier.php");
			
			$connexion = mysql_connect("localhost", "root", "");
	                mysql_select_db("boutique", $connexion);

			
			$requete = "SELECT * FROM panier WHERE id='$indice' ";
     			$result = mysql_query($requete);
			$panier_liste=mysql_fetch_array($result);
			
			//var_dump($panier_liste);
			
	    		$articles = explode("," , $panier_liste['panier']);
	  	     	
	  	     	//echo "+++++";
	  	     	print_r($articles);
	  	     	
	  	     	$nb_articles = count($articles)/3; 
			
			echo $nb_articles;
			
			 // 0 3 6 
			 
			 
			$ptr = 0;
			 
			//NTH82K, 3, 1438.5, X28Z-22, 3, 2164.5 
			// 0      1    2      3       4   5 
			
			$connexion = mysql_connect("localhost", "root", "");
     		   	mysql_select_db("boutique", $connexion);
			
			
//			$str = utf8_decode($str);

			
				
				
				
				$ref = $articles[$ptr];
				$ref = trim($ref);
				
				$connexion = mysql_connect("localhost", "root", "");
       		   		mysql_select_db("boutique", $connexion);
				$requete = "SELECT * FROM lave_linge WHERE modele='$ref'";
			         $result = mysql_query($requete);
				 $data  = mysql_fetch_assoc($result);
		
				var_dump($data);
				
				$ptr = $ptr + 3;
				
				echo "+++++";
				
				$ref = $articles[$ptr];
				$ref = trim($ref);
				
				$connexion = mysql_connect("localhost", "root", "");
       		   		mysql_select_db("boutique", $connexion);
				$requete = "SELECT * FROM lave_linge WHERE modele='$ref'";
			         $result = mysql_query($requete);
				 $data  = mysql_fetch_assoc($result);
		
				var_dump($data);
				
				
				
		
				 //$select['id'] = $data['id'];
	      			 //$select['designation'] = $data['modele'];	
				 //$select['qte'] = $articles[1+$ptr];;
				 //$select['prix_ttc'] = $data['prix_ttc'];
				 //$select['prix_ht'] = $data['prix_ht'];
				 //ajout($select);
				
				 
				 
			
			
				//$io = "X28Z-22";
			
				 //$requete = "SELECT * FROM lave_linge WHERE modele='$io'";
			        // $result = mysql_query($requete);
				// $data  = mysql_fetch_assoc($result);
				 
				 
			
				
			
			// affiche le contenu du tableau panier stocké dans la variable globale $_SESSION
			
			
			 //header('Location: ajouter_panier.php'); 

	

	
?>


<?php
function ajout($select)
{
    array_push($_SESSION['panier']['id'],$select['id']);
    array_push($_SESSION['panier']['qte'],$select['qte']);
    array_push($_SESSION['panier']['designation'],$select['designation']);
    array_push($_SESSION['panier']['prix_ttc'],$select['prix_ttc']);
    array_push($_SESSION['panier']['prix_ht'],$select['prix_ht']);
} 

?>	