Bonjour à tous !
Voilà, je suis un peu bloquer sur un code et souhaiterais que vous m'aidez.
J'ai une page qui génère un bon de commande dont les input ont des id incrément +i
Je dois récupérer donc ces éléments dans une autre page qui les injectera dans ma base de donnée.
J'essaie d'être le plus explicite possible, merci de votre aide.
Voici la page où le bon de commande est rempli :
Et voici celle qui doit injecter les éléments dans ma table :
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
63
64
65
66
67
68
69
70
71
72 <form method="POST" name="Form" autocomplete="OFF" enctype="multipart/form-data" action="voucher_ajouter.php"> <input type="hidden" name="action" value="send" /> <input type="hidden" name="access[]" value="home" /> <input type="text" name="Fr_Nom" id="Fr_Nom" value=""> <input type="text" name="Fr_Carte" id="Fr_Carte" value=""> <input type="text" name="Fr_Bon" id="Fr_Bon" value=""> <input type="text" name="Fr_Date" id="Fr_Date" value=""> <input type="hidden" name="Fr_Total" id="Resultat_input" value="0"> <input type="hidden" name="Fr_Pourcentage" id="Pourcentage_input" value="0"> <input type="submit" name="button" class="btn btn-large btn-primary" value="Valider le bon de commande" /> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" id="TableauJaquery1" class="Tableau"> <thead> <tr> <th align="center"><strong>Libellé</strong></th> <th width="80" align="center"><strong>Quantité</strong></th> <th width="100" align="center"><strong>Prix</strong></th> <th width="100" align="center"><strong>Total</strong></th> </tr> </thead> <tbody> <?php $Stat = $pdo->query("SELECT * FROM " . $TB_PRODUITS . " WHERE " . $PAYS . "='1' AND Activer = 1 AND Stock = '1' ORDER BY Marque ASC; "); $i = 0; while ($data = $Stat->fetch(PDO::FETCH_ASSOC)) { ?> <tr> <td align="left" valign="middle"><div style="display:none;"><?php echo $data["Libelle"] . " " . $data["Contenance"]; ?></div> <input type="text" class="span2" id="Fr_Libelle_<?php echo $i; ?>" style="width:100%; text-align:left; margin:0;" readonly value="<?php echo $data["Libelle"] . " " . $data["Contenance"]; ?>" > </td> <td align="center" valign="middle"> <input type="text" class="span2" id="Fr_Quantite_<?php echo $i; ?>" style="width:100%; text-align:center; margin:0;" maxlength="2" value="0" oninput="calcul('<?php echo $i; ?>')"> </td> <td align="right" valign="middle"> <input type="text" class="span2" id="Fr_Prix_<?php echo $i; ?>" style="width:100%; text-align:right; margin:0;" maxlength="2" readonly value="<?php echo $data["Prix"]; ?>" oninput="calcul('<?php echo $i; ?>')"> </td> <td align="right" valign="middle"> <input type="text" class="span2" id="Fr_Total_<?php echo $i; ?>" style="width:100%; text-align:right; margin:0;" maxlength="2" readonly value="0"> </td> </tr> <?php $i++; } ?> </tbody> </table> </div> </form>
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 <?php $Fr_Nom = trim(strip_tags($_POST["Fr_Nom"])); $Fr_Carte = trim(strip_tags($_POST["Fr_Carte"])); $Fr_Bon = trim(strip_tags($_POST["Fr_Bon"])); $Fr_Date = trim(strip_tags($_POST["Fr_Date"])); $Fr_Total = trim(strip_tags($_POST["Fr_Total"])); $Fr_Pourcentage = trim(strip_tags($_POST["Fr_Pourcentage"])); $Fr_Libelle = trim(strip_tags($_POST["Fr_Libelle"])); $Fr_Quantite = trim(strip_tags($_POST["Fr_Quantite"])); $Fr_PrixUnit = trim(strip_tags($_POST["Fr_PrixUnit"])); $Fr_PrixTotal = trim(strip_tags($_POST["Fr_PrixTotal"])); $Fr_Nom = !empty($Fr_Nom) ? "$Fr_Nom" : NULL; $Fr_Carte = !empty($Fr_Carte) ? "$Fr_Carte" : NULL; $Fr_Bon = !empty($Fr_Bon) ? "$Fr_Bon" : NULL; $Fr_Date = !empty($Fr_Date) ? "$Fr_Date" : NULL; $Fr_Total = !empty($Fr_Total) ? "$Fr_Total" : NULL; $Fr_Pourcentage = !empty($Fr_Pourcentage) ? "$Fr_Pourcentage" : NULL; $Fr_Libelle = !empty($Fr_Libelle) ? "$Fr_Libelle" : NULL; $Fr_Quantite = !empty($Fr_Quantite) ? "$Fr_Quantite" : NULL; $Fr_PrixUnit = !empty($Fr_PrixUnit) ? "$Fr_PrixUnit" : NULL; $Fr_PrixTotal = !empty($Fr_PrixTotal) ? "$Fr_PrixTotal" : NULL; $FR_PDO = $pdo->prepare("INSERT INTO tb_user_voucher (Nom, Carte, Bon, Date, Total, Pourcentage, Libelle, Quantite, PrixUnit, PrixTotal) VALUES (:Fr_Nom, :Fr_Carte, :Fr_Bon, :Fr_Date, :Fr_Total, :Fr_Pourcentage, :Fr_Libelle, :Fr_Quantite, :Fr_PrixUnit, :Fr_PrixTotal)"); $FR_PDO->execute(array( "Fr_Nom" => $Fr_Nom, "Fr_Carte" => $Fr_Carte, "Fr_Bon" => $Fr_Bon, "Fr_Date" => $Fr_Date, "Fr_Total" => $Fr_Total, "Fr_Pourcentage" => $Fr_Pourcentage, "Fr_Libelle" => $Fr_Libelle, "Fr_Quantite" => $Fr_Quantite, "Fr_PrixUnit" => $Fr_PrixUnit, "Fr_PrixTotal" => $Fr_PrixTotal ));
Je sais que l'insert ajoute une ligne dans la table, mais ici, il faudrait que chaque ligne du tableau dont la valeur de la quantité est = à 0 s'enregistre avec les autres infos de l'utilisateur.
Pouvez-vous m'aider à résoudre ce problème svp ?
Cordialement
Partager