trié un ableau avec plusieur colonne
Posté : 31 mai 2011, 14:51
bonjour, j'ai créée un tableau en php et html et je voudrais faire le tri pour chaque colonne de ce tabeau , c'est à direquand je clique sur la colonne client le tabeau sera trié selon le nom client, et quand je clique sur num commande le tableau sera trié par le num d commande.
merci d'avance pour votre aide
mysql_select_db($database_connexion, $connexion);
$query_commandes = sprintf("SELECT * FROM shop_commande ORDER BY id DESC");
$commandes = mysql_query($query_commandes, $connexion) or die(mysql_error());
$row_commandes = mysql_fetch_assoc($commandes);
$totalRows_commandes = mysql_num_rows($commandes);
<table width="100%" cellpadding="5" cellspacing="1" bgcolor="#666666">
<tr bgcolor="#FFFFFF">
<th scope="col"><span class="Style1 Style1">Numéro de commande </span></th>
<th scope="col"><span class="Style1 Style1">Numéro de facture </span></th>
<th scope="col"><span class="Style1 Style1">Client </span></th>
<th scope="col"><span class="Style1 Style1">Poids </span></th>
<th scope="col"><span class="Style1 Style1">Total TTC </span></th>
<th scope="col"><span class="Style1">Date de Commande </span></th>
<th scope="col"><span class="Style1 Style1">Facture format PDF</span></th>
</tr>
<?php do { ?>
<?php
$date =$row_commandes['date'];
$total_ht =$row_commandes['total_ht'];
$c_total_ttc =$row_commandes['total_ttc'];
$expedition =$row_commandes['expedition'];
$client=$row_commandes['client'];
//$zone = $row_client['zone'];
$date_french= preg_replace("/([0-9].*)-([0-9].*)-([0-9].*)/" ,"\\3-\\2-\\1",$date);
$date_expedition= preg_replace("/([0-9].*)-([0-9].*)-([0-9].*)/" ,"\\3-\\2-\\1",$expedition);
$total_ttc_arrondi= number_format($c_total_ttc, 2, ',', ' ');
$date_explosee = explode("-", $date);
$annee = $date_explosee[0];
$mois = $date_explosee[1];
$jour = $date_explosee[2];
$id =$row_commandes['id'];
$id = 1000+$id;
?>
<tr bgcolor="#FFFFFF">
<td><a href="../account/detail_commande.php?id=<?php echo $row_commandes['id']; ?>" class="Style1 Style1">n°<?php echo $row_commandes['id']; ?></a></td>
<td><div align="center"><span class="Style1 Style1">n°<?php echo $annee; ?>/<?php echo $id; ?></span></div></td>
<td><div align="center"><span class="Style1 Style1"><?php echo $row_commandes['client']; ?></span></div></td>
<td><div align="right"><span class="Style1 Style1"><?php echo $row_commandes['poids']; ?>gr.</span></div></td>
<td><div align="right"><span class="Style1 Style1"><?php echo $total_ttc_arrondi; ?>€</span></div></td>
<td><div align="center"><span class="Style1"><?php echo $date_french; ?></span></div></td>
<td><div align="center"><span class="Style1"><a href="traitementAdmin_facture.php?id=<?php echo $row_commandes['id']; ?>">Facture</a></span></div></td>
</tr>
<?php } while ($row_commandes = mysql_fetch_assoc($commandes)); ?>
</table> merci d'avance pour votre aide