| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 
 | $epi=$_GET['epi'];
$quantite=$_GET['quantite'];
$nomepi=$_GET['nomepi'];
 
$query = 'INSERT INTO `epi`.`appro` (`Nom`,`Code_EPI`,`Quantite`) VALUES (:Nom,:Code_EPI,:Quantite)';
$mes = $pdo->prepare( $query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
$a=$mes->execute(array(
            ":Nom" =>$nomepi,
            ":Code_EPI" => $epi,
            ":Quantite" => $quantite
	        ));
 
			$query = "SELECT DISTINCT Code_EPI FROM stock"; 
			$mes = $pdo->prepare( $query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
			$mes->execute();// Requête SQL
			// On fait une boucle pour lister tout ce que contient la table :
            foreach($mes->fetchall() as $t){
 
						 If ($epi = $t) {
							 	$epi=$_GET['epi'];
							 $query = "SELECT DISTINCT Stock FROM stock WHERE Code_EPI = :Code_EPI"; 
							 $mes = $pdo->prepare( $query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
							 $mes->execute(array(
							 ":Code_EPI" => $epi
							 ));
 
 
							 foreach($mes->fetchall() as $t){						
							 $query = "UPDATE `epi`.`stock` SET `Stock` = :Stock WHERE Code_EPI = :Code_EPI"; 
							 $mesi = $pdo->prepare( $query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
							 $b=$mesi->execute(array(
 
								":Stock" =>$t['Stock'] + $quantite, 
								":codeEPI" => $epi
								));	
							 }
											}		
			} | 
Partager