Bonjour,
Je cherche à faire une sorte de panier pour un logiciel de caisse, et mon problème c'est que je ne vois pas trop par ou commencer pour stocker les articles (on renseigne l'id ou la désignation( dans mon code, ne pas tenir compte de la désignation elle doit être le même principe que la recherche avec l'id)puis ça nous rajouter des lignes à un tableau contenant les articles précédemment saisie) sachant qu'à chaque fois qu'on renseigner un id ou désignation sa recharge la page.
Voilà se qui j'ai fais pour le moment :
Je sais que ce n'est pas possible de faire la partie avec le fetch, mais dans le principe c'est l'idée
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 <?php require_once('inc/inc.php'); session_start(); $_SESSION['panier'] = array(); $_SESSION['panier']['designation'] = array(); $_SESSION['panier']['id'] = array(); $_SESSION['panier']['prix'] = array(); ?> <html lang="fr"> <head> <meta charset="utf-8"> <link rel="stylesheet" href="Styles/Style.css"> <title>Caisse :</title> </head> <body> <a href="Index.php" class="buton">Retour</a> <?php if(isset($messageR) AND !empty($messageR)) { echo"<p id=\"alerteR\">$messageR</p>"; } ?> <div class="zone_ass"> <table> <table class="zone_tab"> <tr> <th class="zone_tab_l_top">Id</th> <th class="zone_tab_l_top">Designation</th> <th class="zone_tab_l_top">Prix TTC</th> </tr> <tr> <td class="zone_tab_l"> <p><form action="" method="post"> <?php if(isset($_POST) and !empty($_POST['id_R'])){ $id = $_POST['id_R']; $article = $bdd->prepare('SELECT * FROM f_articles WHERE id = ?'); $article->execute(array($id)); if($article->rowCount($article) == 1){ while($data = $article->fetch()) { $desig = $data['designation']; $prix = $data['prix']; } $_SESSION['panier']['designation'] = $desig; $_SESSION['panier']['prix'] = $prix; $_SESSION['panier']['id'] = $id; }else{ $messageR = "L'article n'est pas créé!!"; } } ?> <input name="id_R" class="i_caisse" placeholder="id"> </form></p> </td <td class="zone_tab_l"> <p> <form action="" method="post"> <?php if(isset($_POST) and !empty($_POST['design_R'])){ $desig = $_POST['design_R']; $article = $bdd->prepare('SELECT * FROM f_articles WHERE designation = ?'); $article->execute(array($desig)); if($article->rowCount($article) == 1){ while($data = $article->fetch()) { $id = $data['id']; $prix = $data['prix']; } }else{ $messageR = "L'article n'est pas créé!!"; } } ?> <input name="design_R" class="i_caisse" placeholder="Designation"> </form> </p> </td> <td class="zone_tab_l"> <p></p> </td> </tr> <?php while($article_passe = $_SESSION['panier']->fetch()){ ?> <tr> <td class="zone_tab_l"> <p> <?=$article_passe['id']?> </p> </td> <td class="zone_tab_l"> <p> <?=$article_passe['designation']?> </p> </td> <td class="zone_tab_l"> <p> <?=$article_passe['prix']?> </p> </td> </tr> <?php }?> </table> </div> </body> </html>
J'espère que vous m'aurez compris
Merci d'avance
Partager