recuperation du sens de tri d'une colonne
Posté : 14 avr. 2007, 15:05
Bonjour,
j'esssaie de trier un tableau sur les titres des colonnes.
j'arrive a trier mais toujours par asc.
or dans le cas ou l'on reclique sur un titre j'aimerais que le tri s'inverse
j'espere que quelqu'un pourra m'aider
voici le code
j'esssaie de trier un tableau sur les titres des colonnes.
j'arrive a trier mais toujours par asc.
or dans le cas ou l'on reclique sur un titre j'aimerais que le tri s'inverse
j'espere que quelqu'un pourra m'aider
voici le code
Code : Tout sélectionner
<div id="table_liste">
<table summary="Liste des tôles INOX en stock à la CDE">
<?php $date= date("j/m/Y");
$tri= "$order";
if (isset($_GET["order"])){
$order = $_GET[order];
if ($order ==$tri){
$sens = "desc";
}else{
$sens = "asc";
}
}else{
$order= " NUM_TOLE asc";
}
?>
<caption>Stock des tôles INOX au <?php print "$date"; ?></caption>
<tr>
<th><a href="index.php?op=liste_tole_in&order=NUM_TOLE">numéro</a></th>
<th><a href="index.php?op=liste_tole_in&order=MAT_TOLE">matière</a></th>
<th>N° coulée</th>
<th>Largeur</th>
<th>Longueur</th>
<th><a href="index.php?op=liste_tole_in&order=EPAIS_TOLE">Epaisseur</a></th>
<th><a href="index.php?op=liste_tole_in&order=EMPL_TOLE">Emplacement</a></th>
<th>Affectation</th>
<th>Observations</th>
</tr>
<?php $query_liste_tole_inox = "SELECT ID_TOLE, NUM_TOLE, MAT_TOLE, COUL_TOLE, LARG_TOLE, LONG_TOLE, EPAIS_TOLE, AFFEC_TOLE, N_AFF_TOLE, EMPL_TOLE, OBSER_TOLE FROM tole_cde order by '$order' '$sens '";
$result_liste_tole_inox = mysql_query($query_liste_tole_inox) or die("Erreur dans la requête query_liste_tole_inox");
while ($row_liste_tole_inox = mysql_fetch_array($result_liste_tole_inox, MYSQL_NUM)) {
$id__tole_inox=$row_liste_tole_inox[0];
print "<input type=\"hidden\" name=\"id\" size=40 maxlength=40 value=\"$id_arti\">";
$num_tole_inox=$row_liste_tole_inox[1];
$mat_tole_inox=$row_liste_tole_inox[2];
$coul_tole_inox=$row_liste_tole_inox[3];
$larg_tole_inox=$row_liste_tole_inox[4];
$long_tole_inox=$row_liste_tole_inox[5];
$epais_tole_inox=$row_liste_tole_inox[6];
$affec_tole_inox=$row_liste_tole_inox[7];
$naff_tole_inox=$row_liste_tole_inox[8];
$empla_tole_inox=$row_liste_tole_inox[9];
$obser_tole_inox=$row_liste_tole_inox[10];
?>
<tr>
<td width="11%" ><?php print"$num_tole_inox"; ?></td>
<td width="11%"><?php print "$mat_tole_inox"; ?></td>
<td width="11%"><?php print "$coul_tole_inox"; ?></td>
<td width="11%"><?php print "$larg_tole_inox"; ?></td>
<td width="11%"><?php print "$long_tole_inox"; ?></td>
<td width="11%"><?php print "$epais_tole_inox"; ?></td>
<td width="11%"><?php print "$empla_tole_inox"; ?></td>
<?php
if($affec_tole_inox==1){
?>
<td width="11%"><?php print "stock"; ?></td>
<?php
}else{
?>
<td width="11%"><?php print "affaire<br>$naff_tole_inox"; ?></td>
<?php
}
?>
<td width="11%"><?php print "$obser_tole_inox"; ?></td>
<?php } ?>
</tr>
</tr>
</table>
</div>