Faire un tri ou filtre
Résolu
tridam23
Messages postés
104
Statut
Membre
-
tridam23 Messages postés 104 Statut Membre -
tridam23 Messages postés 104 Statut Membre -
bonjour
j'ai ce code
je souhaiterai avoir la possibilité de trier les éléments par classe des élèves
genre tu clique tu classe et il te les classe en croissant ou décroissant
et aussi exemple, tu sélectionne 3ème A et seul ces élèves là s'affiche
merci de votre aide
début en la matière
--
www.tremvi.com www.bawolo.com www.biz243.com
j'ai ce code
<?php
session_start();
if (!(isset($_SESSION['NIV'])))
header("location:index.html");
?>
<?php
require_once("connection.php");
$req = "select * from ELEVES";
$rs = mysql_query($req) or die(mysql_error());
?>
<html>
<head>
<meta charset="utf-8">
<title>Affichage des élèves</title>
<link href="stle.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="500" border="0">
<tr>
<td><a href="saisieEleve.html"><br>Inscrire un élève</a></td>
<td><a href="ChercherEleves.php"><br>Rechercher un élève</a></td>
<td><a href="index.html"><br>Accueil</a></td>
</tr>
</table>
<br>
<table border="1" width="50%">
<tr>
<th>CODE</th>
<th>PHOTO</th>
<th>CLASSE</th>
<th>INSCRIPTION</th>
<th>NOM</th>
<th>PRENOM</th>
<th>POSTNOM</th>
<th>NAISSANCE</th>
<th>SEXE</th>
<th>NATIONALITE</th>
<th>ADRESSE</th>
<th>PERE</th>
<th>TEL PERE</th>
<th>ADRESSE DOMICILE</th>
</tr>
<?php while ($ET = mysql_fetch_assoc($rs)) { ?>
<tr>
<td><?php echo($ET['CODE']) ?></td>
<td><img src="images/<?php echo($ET['PHOTO']) ?>" width="90" height="113"</td>
<td><?php echo($ET['CLASSE']) ?></td>
<td><?php echo($ET['INSCRIPTION']) ?></td>
<td><?php echo($ET['NOM']) ?></td>
<td><?php echo($ET['PRENOM']) ?></td>
<td><?php echo($ET['POSTNOM']) ?></td>
<td><?php echo($ET['NAISSANCE']) ?></td>
<td><?php echo($ET['SEXE']) ?></td>
<td><?php echo($ET['NATIONALITE']) ?></td>
<td><?php echo($ET['ADRESSE']) ?></td>
<td><?php echo($ET['PERE']) ?></td>
<td><?php echo($ET['TELPERE']) ?></td>
<td><?php echo($ET['ADRESSE1']) ?></td>
<?php if ($_SESSION['NIV'] == 0) { ?>
<td><a href="supprimerEleve.php?code=<?php echo($ET['CODE']) ?>" class="bouton">Supprimer</a></td>
<td><a href="editEleve.php?code=<?php echo($ET['CODE']) ?>" class="bouton">Editer</a></td>
<?php } ?>
</tr>
<?php } ?>
</table>
</body>
</html>
je souhaiterai avoir la possibilité de trier les éléments par classe des élèves
genre tu clique tu classe et il te les classe en croissant ou décroissant
et aussi exemple, tu sélectionne 3ème A et seul ces élèves là s'affiche
merci de votre aide
début en la matière
--
www.tremvi.com www.bawolo.com www.biz243.com
1 réponse
-
Bonjour,
Avant de poursuivre...
tu clique tu classe et il te les classe en croissant ou décroissant
et aussi exemple, tu sélectionne 3ème A et seul ces élèves là s'affiche
... Tu cliques où ? sur quoi ? à quel endroit de ton code ?
... Tu selectionnes quoi / où ... ?
En fonction de ces réponses... des propositions pourront t'être faites.
-
-
-
plus simple (je vais essayer)
A partir des résultats qui s'affichent sur ce tableau,
comment faire pour avoir la possibilité de trier les informations dans la colonne <th>CLASSE</th>
Exemple : dans l'école, il y a les classes de 1er, 2ème, 3ème, 4ème, 5ème et 6ème
les informations sont saisis. et par exemple le professeur souhaite avoir les résultats par classe. mettre d'abord les élèves de 1er, 2ème, etc...
j'espère que ca va comme explication -
-
A partir des résultats qui s'affichent sur ce tableau,
comment faire pour avoir la possibilité de trier les informations dans la colonne <th>CLASSE</th>
Tu pourrais éventuellement utiliser le plugin javascript (jquery) Tablesorter.js
https://closed.loopia.com
Cela évite de devoir recharger la page.
Après... (surtout si tu utilises de la tabulation avec du LIMIT ... ) le mieux reste de le faire en REQUETE ...
Un truc du genre (utilisant les variables GET )
<?php session_start(); if (!(isset($_SESSION['NIV']))){ header("location:index.html"); } require_once("connection.php"); $order = isset($_GET['order'])?$_GET['order']:'ASC'; $req = "select * from ELEVES ORDER BY nomduchamp $order "; $rs = mysql_query($req) or die(mysql_error()); $thOrder = $order == 'ASC'? 'DESC' : 'ASC'; ?> <html> <head> <meta charset="utf-8"> <title>Affichage des élèves</title> <link href="stle.css" rel="stylesheet" type="text/css"> </head> <body> <table width="500" border="0"> <tr> <td><a href="saisieEleve.html"><br>Inscrire un élève</a></td> <td><a href="ChercherEleves.php"><br>Rechercher un élève</a></td> <td><a href="index.html"><br>Accueil</a></td> </tr> </table> <br> <table border="1" width="50%"> <tr> <th>CODE</th> <th>PHOTO</th> <th><a href="?order=<?php echo $thOrder; ?>" >CLASSE </a></th> <th>INSCRIPTION</th> <th>NOM</th> <th>PRENOM</th> <th>POSTNOM</th> <th>NAISSANCE</th> <th>SEXE</th> <th>NATIONALITE</th> <th>ADRESSE</th> <th>PERE</th> <th>TEL PERE</th> <th>ADRESSE DOMICILE</th> </tr> <?php while ($ET = mysql_fetch_assoc($rs)) { ?> <tr> <td><?php echo($ET['CODE']) ?></td> <td><img src="images/<?php echo($ET['PHOTO']) ?>" width="90" height="113"</td> <td><?php echo($ET['CLASSE']) ?></td> <td><?php echo($ET['INSCRIPTION']) ?></td> <td><?php echo($ET['NOM']) ?></td> <td><?php echo($ET['PRENOM']) ?></td> <td><?php echo($ET['POSTNOM']) ?></td> <td><?php echo($ET['NAISSANCE']) ?></td> <td><?php echo($ET['SEXE']) ?></td> <td><?php echo($ET['NATIONALITE']) ?></td> <td><?php echo($ET['ADRESSE']) ?></td> <td><?php echo($ET['PERE']) ?></td> <td><?php echo($ET['TELPERE']) ?></td> <td><?php echo($ET['ADRESSE1']) ?></td> <?php if ($_SESSION['NIV'] == 0) { ?> <td><a href="supprimerEleve.php?code=<?php echo($ET['CODE']) ?>" class="bouton">Supprimer</a></td> <td><a href="editEleve.php?code=<?php echo($ET['CODE']) ?>" class="bouton">Editer</a></td> <?php } ?> </tr> <?php } ?> </table> </body> </html>
-