Bonjour ou bonsoir à tous,
Je suis sur un panier et j'affiche les produits ajoutés au panier dans mon panier.php
Seulement j'aimerai enregistrer tout ces produits en BDD. Et là je bloque.
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106 <form method="post" action="recap.php" enctype="multipart/form-data"> <p class="entete"> <span class="col_0"></span> <span class="col_01">Nom</span> <span class="col_1">Format</span> <span class="col_2">Prix</span> <span class="col_3">Quantité</span> <span class="col_4">Prix total</span> <span class="col_5">Supprimer</span> </p> <?php $ids = array_keys($_SESSION['panier']); if(empty($ids)){ $products = array(); }else{ $products = $DB->query('SELECT * FROM images WHERE id IN ('.implode(',',$ids).')'); } foreach($products as $product): ?> <p class="ligne"> <span class="col_0"> <a href="#" class="img"> <img src="administration/images/<?= print $album; ?>/<?= $product->thumbnail_image; ?>" height="53"></a> </span> <span class="col_01 info-nom"><?= $product->normal_name; ?></span> <span class="col_1"> <select name="prix[<?= $product->id; ?>]"> <?php $formats = $DB->query("SELECT * FROM produits"); ?> <?php foreach ( $formats as $format ): ?> <option value="<?= $format->prix; ?>"><?= $format->format_name; ?></option> <?php endforeach ?> </select> </span> <span class="col_2 info-prix"></span> <span class="col_3"> <button type="button" class="btn_moins">-</button> <input type="text" name="quantite[<?= $product->id; ?>]"> <button type="button" class="btn_plus">+</button> </span> <span class="col_4 total-ligne"></span> <span class="col_5"> <a href="panier.php?delPanier=<?= $product->id; ?>" class="del"><img src="panier/img/del.png" title="Supprimer l'élément" alt ="supprimer l'élément"></a> </span> </p> <?php endforeach; ?> <p class="totaux"> <span></span> <span></span> <span></span> <span></span> <span> <input type="text" value ="<?php print $_SESSION['identifiantv'];?>" name="identifiantv" id="identifiantv"> <input type="text" id="idalbum" name="idalbum" value="<?php print $album;?>"> </span> <span class="text-right">Total HT :</span> <span id="totalht" class="text-right"></span> </p> <p class="totaux"> <span></span> <span></span> <span></span> <span></span> <span></span> <span class="text-right">Tva :</span> <span id="tva" class="text-right"></span> </p> <p class="totaux"> <span></span> <span></span> <span></span> <span></span> <span></span> <span class="text-right">Total TTC :</span> <span id="total" class="text-right"></span> </p> <input type="submit" value="continuer"> </form>
Si je fais uncela me renvoie :print_r($_POST);
Ma page recap.phpArray ( [prix] => Array ( [11] => 3.9 [13] => 3.9 [20] => 3.9 ) [quantite] => Array ( [11] => 5 [13] => 2 [20] => 4 ) [identifiantv] => 57225da1d7df7 [idalbum] => test )
J'aimerai enregistrer tout ces produits en BDD et les afficher dans ma page recap.php
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 <?php $album=$_SESSION['login']; ?> <input type="text" value ="<?php print $_POST['identifiantv'];?>" name="identifiantv" id="identifiantv"> <input type="text" id="idalbum" name="idalbum" value="<?php print $_POST['idalbum'];?>"> <? // on teste la déclaration de nos variables if (isset($_POST['quantite[]']) && isset($_POST['prix[]'])) { // on affiche nos résultats echo 'Vos quantités '.$_POST['quantite[]'].' et vos prix '.$_POST['prix[]']; } else { echo 'erreur qq part...' ;} ?> <?php print $_POST['quantite[]']; ?> <?php print_r($_POST); ?>
Je ne souhaite pas forcément une réponse toute faite (quoique) mais j'aimerai surtout comprendre le raisonnement.
Comment puis-je m'y prendre ?
Merci de votre aide
Partager