Bonsoir à tous,
Alors voila j'ai trouvé un moyen pour que, quand je tape la référence d'un article, il me renvoie le nom du produit.
Le problème étant que ces deux informations : ref_produit et nom_produit sont maintenant dans deux pages avec un formulaire.
Et moi je veux intégrer tout cela dans un formulaire existant en "POST"
Pour être plus clair :
Le user doit entrer en stock un article il saisit la ref. le nom du produit apparait tout seul. Il saisit la quantité et valide manuellement en submit. Comment faire ? merci d'avance
suivi de recherche_non.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
25
26
27
28
29
30
31
32
33
34 <html> <head> <script> function showUser(str) { if (str == "") { document.getElementById("txtHint").innerHTML = ""; return; } else { var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("txtHint").innerHTML = this.responseText; } }; xmlhttp.open("GET","recherche_nom.php?q="+str,true); xmlhttp.send(); } } </script> </head> <body> <form method="GET"> <label for="ref_produit">ref du produit</label> <input name="ref_produit" onchange="showUser(this.value)"> </input> </form> <br> <div id="txtHint"><b>Person info will be listed here...</b></div> </body> </html>
voila le formulaire sur lequel je dois insérer tout cela :
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 <!DOCTYPE html> <html> <head> <style> table { width: 100%; border-collapse: collapse; } table, td, th { border: 1px solid black; padding: 5px; } th {text-align: left;} </style> </head> <body> <?php $q = intval($_GET['q']); $con = mysqli_connect('localhost','root',''); if (!$con) { die('Could not connect: ' . mysqli_error($con)); } mysqli_select_db($con,"stock"); $sql="SELECT * FROM article WHERE ref_produit = '".$q."'"; $result = mysqli_query($con,$sql); while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['nom_produit'] . "</td>"; echo "</tr>"; } echo "</table>"; mysqli_close($con); ?> </body> </html>
je vous remercie d'avance
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 <?php include 'entete.php'; $bienvenue= $_SESSION["login"]; ?> <div class="home-content"> <div class="overview-boxes"> <div class="box_form"> <form action="entree_article.php" method="POST"> <label for="ref_produit">id du produit</label> <input type="integer" name="e_ref_produit" id="e_ref_produit" placeholder="Saisir le code barre de la tote"> <label for="stock_actuel">Quantité entrée</label> <input type="number" name="quantite_entree" id="quantite_entree" placeholder="Saisir la quantité"> <label for="e_login">Fait par</label> <input type="hidden" name="e_login" id="e_login" value="<?php echo $bienvenue?>"> <input type="submit" name="valider" value="valider" /> <?php if (!empty($_SESSION ['messageentree']['text'])) { ?> <div class="alert <?= $_SESSION ['messageentree']['type'] ?>"> <?= $_SESSION ['messageentree']['text'] ?> </div> <?php } ?> </form> </div> <div class="box2"> <table class="mtable"> <tr> <th>Date</th> <th>Ref article</th> <th>Nom article</th> <th>Quantité entrée</th> <th>Entrée faite par </th> </tr> <?php $entree = getEntree(); if (!empty($entree) && is_array($entree)) { foreach ($entree as $key => $value) { ?> <tr> <td><?= date("d/m/Y" , strtotime ($value['date'])) ?></td> <td><?= $value['e_ref_produit'] ?></td> <td><?= $value['nom_produit'] ?></td> <td><?= $value['quantite_entree'] ?></td> <td><?= $value['e_login'] ?></td> </tr> <?php } } ?> </table> </div> </div> </div> </section>
Partager