Commit 6895c35d62d6ce90db12c5a2cf30851cfd05c3d6
1 parent
5464dee3
Prix de la bière selon quantité
Showing
1 changed file
with
8 additions
and
3 deletions
Show diff stats
api/client/payer.php
... | ... | @@ -14,18 +14,23 @@ if (!clientExiste(donne("idCarte"))) { |
14 | 14 | |
15 | 15 | if (donne("quantite")) { |
16 | 16 | $quantite = intval($_POST["quantite"]); |
17 | - $requete = $db->prepare("SELECT prix FROM Prix"); | |
17 | + $requete = $db->prepare("SELECT prix FROM Prix WHERE produit=?"); | |
18 | 18 | if (!$requete) { |
19 | 19 | retour("erreur_bdd_preparee", ["message" => $db->error]); |
20 | 20 | } |
21 | + $produit = "biere" . $quantite; | |
22 | + $requete->bind_param("s", $produit); | |
21 | 23 | $requete->bind_result($prixItem); |
22 | 24 | if (!$requete->execute()) { |
23 | 25 | retour("erreur_bdd", ["message" => $requete->error]); |
24 | 26 | } |
25 | - $requete->fetch(); | |
27 | + if (!$requete->fetch()) { | |
28 | + retour("produit_inconnu"); | |
29 | + } | |
26 | 30 | $requete->close(); |
27 | 31 | |
28 | - $montant = $prixItem * $quantite; | |
32 | + // $montant = $prixItem * $quantite; | |
33 | + $montant = $prixItem; | |
29 | 34 | } else { |
30 | 35 | $montant = floatval($_POST["montant"]); |
31 | 36 | $quantite = 0; | ... | ... |