Bonjour,

je veux créer une application web en php et mysql pour faire la gestion de stock

j'ai créer une base de données avec 4 tables (clients , produits , details_facture , facture )

table clients contient les champs suivants : (id,nom,prenom,email,age)
table produit contient les champs suivants : (id,nom_produit,reference,qté,prix,categorie)
table facture contient les champs suivants : (id, id_produit , date, prix_total)
table details_facture contient les champs suivants : (id , id_facture, id_produit,qté, prix)


j'ai créer un formulaire d'ajout de produit et l'ajout d'un client

mais pour la table facture et details_facture je ne sais pas quoi faire ?

Ajout et affichage de liste de produit ca fait dans la meme page (meme chose pour clients) :

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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?php
//include auth.php file on all secure pages
include("auth.php");
?>
 
<!DOCTYPE html>
<html>
<head>
 
  <link rel="stylesheet" href="style1.css" />
 
 
</head>
<body>
<?php
require("db.php");
if (isset($_REQUEST['nom'])) {
 
    $nom = stripcslashes ($_REQUEST['nom']);
    $nom = mysqli_real_escape_string($con,$nom);
 
    $reference = stripcslashes ($_REQUEST['reference']);
    $reference = mysqli_real_escape_string($con,$reference);
 
    $qte = stripcslashes($_REQUEST['qte']);
    $qte = mysqli_real_escape_string($con,$qte);
 
    $prix = stripcslashes($_REQUEST['prix']);
    $prix = mysqli_real_escape_string($con,$prix);
 
    $categorie = stripcslashes($_REQUEST['categorie']);
    $categorie = mysqli_real_escape_string ($con,$categorie);
 
    $query = "INSERT into produits (id,nom ,reference,qte,prix,categorie)
    VALUES (NULL,'".$_POST["nom"]."' ,'".$_POST["reference"]."','".$_POST["qte"]."','".$_POST["prix"]."','".$_POST["categorie"]."')";
 
 
 
        //     $result = mysqli_query($con,$query);
        //     if($result){
        //         echo 'produit bien ajoute';
        //     }}
        // else {
 
          if ($con->query($query) === TRUE) {
            echo "<center><b> Produit Bien Ajoute</b></center> ";
        } else {
            echo "Error: " . $query . "<br>" . $con->error;
        }
 
        $con->close();
 
 
    }else{
 
 
 
    ?>
 
 
<header>
  <h2>Cities</h2>
</header>
 
<section>
  <nav>
    <ul>
      <li><a class="active" href="espace.php">Acceuil</a></li>
      <li><a href="produits.php">Produits </a></li>
      <li><a href="ajoutproduit.php"> Clients </a></li>
    </ul>
 
    <div class="form">
<p> Bienvenue <?php echo $_SESSION['username']; ?>!</p>
<!-- <p>This is secure area.</p> -->
 
<a href="ajoutproduit.php"> Ajouter Un Produit </a><br><br>
<a href="ajoutclient.php"> Ajouter Un Client </a><br><br>
<p><a href="dashboard.php">Dashboard</a></p>
<a href="logout.php"> Déconnexion </a>
</div>
  </nav>
 
  <article>
  <div class="form">
<pre>
    <form  action ="" name="addproduit"  method="post">
 Nom De Produit <input type="text" name="nom" required ><br>
Reference :    <input type="text" name="reference" required ><br>
Quantité :     <input type="text" name="qte"  required ><br>
Prix :         <input type="text" name="prix" required ><br>
Categorie : <select name="categorie" id="categorie">
             <option value="mobile"> Mobile </option>
             <option value="ordinateur"> Ordinateur </option>
             <option value="accessoire"> Accessoire Mobile </option>
             <option value="console"> Console de jeux </option>
</select>
 
<input type="submit" name="submit" value="Ajouter Un Produit" > <button><a href="espace.php"> Retour </a></button>
</form>
</pre>
</div>
 
                  <div class="card">
                         <div class="card-body">
                                    <table class="table table-bordered table-stripped">
                                        <thead>
 
                                            <th>Nom</th>
                                            <th>Reference</th>
                                            <th>Prix</th>
                                            <th>Quantité</th>
                                            <th>Categorie</th>
                                            <th>Option</th>
 
                                        </thead>
                                        <tbody>
                                        <?php 
 
                                          require('db.php');
                                        $res = $con->query("select * from produits order by id desc");
                                        while($data = $res->fetch_assoc()){ 
 
                                         ?>
 
                                        <tr>
 
                                            <td><?php echo $data['nom']; ?></td>
                                            <td><?php echo $data['reference']; ?></td>
                                            <td><?php echo $data['prix']; ?></td>
                                            <td><?php echo $data['qte']; ?></td>
                                            <td><?php echo $data['categorie']; ?></td>
 
 
                                            <td>
                                            <div class="dropdown">
                                                      <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                                        Option
                                                      </button>
                                                      <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                                                        <a class="dropdown-item" href="ajoutproduit.php?update=<?php echo  $data['id'];?>">Modifier</a>
                                                        <a class="dropdown-item" href="ajoutproduit.php?delete=<?php echo $data['id']; ?>">Suprimer</a>
 
    </div>
  </div>
 
 
<!-- 
 
                                                <div class="dropdown">
                                                  <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" >
                                                    Option
                                                  </button>
                                                  <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                                                    <a class="dropdown-item" href="#">Modifier</a>
                                                    <a class="dropdown-item" href="#">Suprimer</a>
 
                                                  </div>
                                                </div>
                                         -->
                                            </td>
                                        </tr>
 
                                        <?php
                                      }
                                      ?>
                                      </tbody>
                                      </table>
                                      </div>
                                                </div> 
 
 
 
<?php } ?>
  </article>
</section>
<!-- 
<footer>
  <p>Footer</p>
</footer> -->
 
 
</body>
 
</html>