Bonjour,

Je souhaite insérer un bouton de tri sur mon formulaire mais je ne sais pas comment mettre le .$orderby dans la requête. Je ne suis pas à l'aise avec la syntaxe.

Code php : 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
 
<form action="index.php" method="GET">
				<input type="submit" name="orderby" value="asc" />
 
 
				<table class="table table-striped table-bordered">
                  <thead>
                    <tr>
                      <th>Code</th>
                      <th>Description</th>
                      <th>Quantité</th>
                      <th>Catégorie</th>
                      <th>Date</th>
                      <th>Actions</th>
                    </tr>
                  </thead>
                  <tbody>
                      <?php
 
                        require 'database.php';
                        $db = Database::connect();
 
						if(isset($_GET['orderby']) && $_GET['orderby'] == "asc") 
						{
   							$orderby = 'ASC';
						}
						else 
						{
					   		$orderby = 'DESC';
						}
 
 
 
 
 
                        $statement = $db->query("SELECT documentation.id, documentation.code_publication_doc, documentation.description, documentation.image, documentation.categorie_publication, documentation.qte_stock, documentation.qte_demande, documentation.date_maj, categories_publications.categorie AS categorie_publication FROM documentation LEFT JOIN categories_publications ON documentation.categorie_publication = categories_publications.id". $orderby);
 
                        while($item = $statement->fetch()) 
                        {
                            echo '<tr>';
                            echo '<td>'. $item['code_publication_doc'] . '</td>';
                            echo '<td>'. $item['description'] . '</td>';
                            //echo '<td>'. number_format($item['qte_stock'], 2, '.', '') . '</td>';
							echo '<td align="center">'. $item['qte_stock'] . '</td>';
                            echo '<td>'. $item['categorie_publication'] . '</td>';
 
							$date_d = $item['date_maj'];
							echo '<td>'. strftime('%d-%m-%Y',strtotime($date_d)) . '</td>';
                            echo '<td width=300>';
                            echo '<a class="btn btn-default" href="view.php?id='.$item['id'].'"><span class="glyphicon glyphicon-eye-open"></span> Voir</a>';
                            echo ' ';
                            echo '<a class="btn btn-primary" href="update.php?id='.$item['id'].'"><span class="glyphicon glyphicon-pencil"></span> Modifier</a>';
                            echo ' ';
                            echo '<a class="btn btn-danger" href="delete.php?id='.$item['id'].'"><span class="glyphicon glyphicon-remove"></span> Supprimer</a>';
                            echo '</td>';
                            echo '</tr>';
                        }
 
 
                        Database::disconnect();
                      ?>
                  </tbody>
                </table>
 
				</form>