Bonjour,

J'essaye de créer un panier où j'aimerais récupérer l'id de chaque produuit a chaque fois que je clique sur celui-ci dans un form submit ainsi que la quantité par $_POST dans une autre page dans un premier temps. Pour l'instant comme je suis débutant en php à chaque fois que je clique sur le bouton submit pour un produit je récupère toujours le dernier id de la liste
Merci pour votre aide !

Voici mon code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
session_start(); //demarrage de la session
 
try
{
	// On se connecte à MySQL
	$bdd = new PDO('mysql:host=localhost;dbname=CaveVin;charset=utf8', '', '');
}
catch(Exception $e)
{
	// En cas d'erreur, on affiche un message et on arrête tout
        die('Erreur : '.$e->getMessage());
}
 
 
$Pseudo=$_SESSION['email'];
echo ' Utilisateur :  '; echo  $Pseudo;
 
 
if (!isset($Pseudo))
{
header('Location: test1.php');
} 
	else
{
?> 
<html>
<form action="panier4_3_test1.php" method="post">
 
<H1 align="center">Boutique de vin en ligne ....</H1>
<table border="1" bgcolor="cccccc" align="center" width="75%">
<tr bgcolor='white'>
<td width=''>Nom Vin</td>
<td width=''>Type Vin</td>
<td width=''>Description Vin</td>
<td width=''>Prix Vin</td>
<td width=''>Capacite Vin</td>
<td width=''>Quantité carton(s)</td>
<td width=''>ID Vin</td>
<td width=''>&nbsp;</td>
</tr>
 
<?php
$sql = $bdd->query("SELECT* FROM Vin ");
while ($data = $sql->fetch()) 
{//la boucle pour l'affichage des données.
?>
     <tr><td><?php echo  $data['nomVin']; ?> 
     </td><td> <?php echo  $data['typeVin']; ?>
      </td><td> <?php echo $data['descriptionVin']; ?>
      </td><td> <?php echo $data['prixVin']; ?> 
      </td><td> <?php echo $data['capaciteVin']; ?> 
      </td><td><input type="text" name="xx" value="<?php echo $data['']; ?>" />
      </td><td><input type="text"  name="number"  value="<?php echo $data['idVin']; ?> "/> 
      </td><td><input type="submit" name="Panier" value="Panier"></input></td></tr>
     <?php
}
}
?>
</form>
<a href="deconnect.php">Déconnection</a>
</html>