Salut a tous,
Je souhaite avoir un ordre d'affichage du bénéfice le plus petit au plus grand. Seulement je ne peux pas le faire avec un ORDER BY car le montant du bénéfice ne vient pas de la bdd, je le calcul plus bas.
Comment faire svp ?
Pour info c'est la variable $nombre_format_francais qui possède le bénéfice final.
Je vous remercie.
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 <table class="table table-striped"> <thead class="thead-dark"> <tr> <th>Réf</th> <th>Objet</th> <th>Prix eBay</th> <th>Frais d'envoi</th> <th>Coût d'achat</th> <th>Bénéfice</th> <th>Modifié le</th> </tr> </thead> <tbody> <?php // Résultat $req = $pdo->query('SELECT id, ref, title, price, shipping, purchase, last_edit FROM ebay ORDER BY ref'); while ($ebay = $req->fetch()) { $prix = $ebay->price; $pourcentage = 25.2; $amount = $prix * (1 - $pourcentage/100) - 0.25; $net = $amount - $ebay->shipping - $ebay->purchase; // Notation française $nombre_format_francais = number_format($net, 2, ',', ' '); $date_format_francais = new DateTime($ebay->last_edit); ?> <tr> <td><a href="https://www.google.fr/search?q=<?= $ebay->ref ?>&tbm=isch" target="_black"><?= $ebay->ref ?></a><br> <a href="https://www.ebay.fr/sch/i.html?_from=R40&_trksid=m570.l1313&_nkw=<?= $ebay->ref ?>&_sacat=0" target="_black">eBay</a></td> <td><a href="modify.php?id=<?= $ebay->id ?>"><img src="img/conf.png"></a> <a href="index.php?del=<?= $ebay->id ?>" onclick="return confirm('Etes vous sûre de vouloir supprimer cette valeur ?');"><img src="img/del.png"></a> <?= $ebay->title ?></td> <td><?= $ebay->price ?></td> <td><?= $ebay->shipping ?></td> <td><?= $ebay->purchase ?></td> <td><strong><?= $nombre_format_francais ?></strong></td> <td><?= $date_format_francais->format('d/m/Y'); ?></td> </tr> <?php } ?> </tbody> </table>
Partager