tonyboy | Salut a tous j'ais fait un petit module de gestion de contacts avec affichage du nom prenom.....
J'ai une liste de plusieur centaine de contacts et je souhaite pouvoir faire un trie par ordre croissan ou decroissan en cliquant sur une image + ou - a conté de chaque champ nom prenom ....
Probleme je n'y arrive pas "please help"
Voici le detail de la partie concerné
Code :
- <TABLE cellSpacing=1 cellPadding=2 border=0 width="100%"><TBODY>
- <TR bgColor=#ffffff>
- <TD>
- <table cellSpacing=1 cellPadding=2 width="100%" border=0>
- <tr>
- <?php
- switch ($listing) {
- case "id-asc":
- $order = "refContact";
- break;
- case "firstname":
- $order = "prenom";
- break;
- case "firstname-desc":
- $order = "prenom DESC";
- break;
- case "lastname":
- $order = "nom";
- break;
- case "lastname-desc":
- $order = "nom DESC";
- break;
- default:
- $order = "refContact DESC";
- }
- ?>
- <td align=center class=entetebleue><a href="<?php echo "$PHP_SELF?listing=lastname"; ?>"><img src="images/ic_up.gif" border="0" alt=" Trier les noms --» A-B-C.." title=" Trier les noms --» A-B-C.."></a> Nom <a href="<?php echo "$PHP_SELF?listing=lastname-desc"; ?>"><img src="images/ic_down.gif" border="0" alt=" Trier les noms --» Z-X-Y.." title=" Trier les noms --» Z-X-Y.."></a></td>
- <td align=center class=entetebleue><a href="<?php echo "$PHP_SELF?listing=firstname"; ?>"><img src="images/ic_up.gif" border="0" alt=" Trier les noms --» A-B-C.." title=" Trier les noms --» A-B-C.."></a> Prenom <a href="<?php echo "$PHP_SELF?listing=firstname-desc"; ?>"><img src="images/ic_down.gif" border="0" alt=" Trier les noms --» Z-X-Y.." title=" Trier les noms --» Z-X-Y.."></a></td>
-
- <td align=center class=entetebleue>Téléphone Mobile </td>
- <td align=left class=entetebleue>Société</td>
- <td align=center colspan=2 class=entetebleue>Action</td>
- </tr>
- <?
- $ligne = 1;
- $result = mysql_query("select refContact, refSociete, nom, prenom, titre, telMobile, telBureau, telStandard, fax, email from tbl_contacts order by $order" );
- while ($row = mysql_fetch_object($result)) {
- $refSociete = $row->refSociete;
- $refContact = $row->refContact;
- $nom = $row->nom;
- $prenom = $row->prenom;
- $telMobile = $row->telMobile;
-
- ?>
- <tr>
- <td class=body align=center bgcolor="<? if ($ligne > 0) echo "ffffff"; else echo "dddddd"; ?>">
- <a href="afficher_contacts.php?refContact=<? echo $refContact ?>&nom=<? echo $nom ?>"><? echo $nom ?></a>
- </td>
- <td class=body align=center bgcolor="<? if ($ligne > 0) echo "ffffff"; else echo "dddddd"; ?>">
- <? echo $prenom ?>
- </td>
- <td class=body align=center bgcolor="<? if ($ligne > 0) echo "ffffff"; else echo "dddddd"; ?>">
- <? echo $telMobile ?>
- </td>
- <td class=body align=left bgcolor="<? if ($ligne > 0) echo "ffffff"; else echo "dddddd"; ?>">
- <? echo getNomSociete($refSociete) ?>
- </td>
- <td class=body align=center bgcolor="<? if ($ligne > 0) echo "ffffff"; else echo "dddddd"; ?>">
- [<a href="modification_contacts.php?refContact=<? echo $refContact ?>&nom=<? echo $nom ?>">Modifier</a>] [<a href="contactsDel.php?refContact=<? echo $refContact ?>&nom=<? echo $nom ?>" onClick="return conf();">Supprimer</a>]
- </td>
- </tr>
- <?
- $ligne = -$ligne;
- }
- mysql_free_result($result);
- ?>
- </table>
- </td>
- </tr>
- </TBODY></table>
|
Et Voici le code source de ma page d'affichage de la liste des contacts
Code :
- <?
- include "globale.inc.php";
- include "fonction.inc.php";
- $conn = connecte();
- ?>
- <html>
- <head>
- <link href="stelsheet.css" rel="stylesheet" type="text/css">
- <script language="JavaScript">
- <!--
- function conf() {
- return (confirm("Etes-vous sur de vouloir supprimer ce Contact ?" ));
- }
- //-->
- </script>
- </head>
- <body class=body>
- <table cellpadding=0 border=0 width=100% valign="top">
- <tr height="100%">
- <td valign="top" class="small" width=150>
- <? include "menu.html" ?>
- </td>
- <td valign="top">
- <TABLE cellSpacing=0 cellPadding=0 border=0 width="100%" align="center" bgColor=#bbbbbb >
- <tr>
- <td>
-
-
- <table cellSpacing=0 cellPadding=3 width="100%" border=0>
- <tr class="enteteblanc" align="center">
- <td width="30" align="left" valign="top"><img src="images/contact.jpg" border="0" width="30" height="30"></td>
- <td width="100%" align="Center" valign="middle" nowrap >.:: liste de tous les Contacts ::. </td>
- <td width="247" align="right" valign="middle" nowrap class="small">Selection Rapide :
- <?
- // Récupération des informations triées par ordre alphabétique
- $menu = "SELECT refContact, nom FROM tbl_contacts ORDER by nom";
- $ReqLog = mysql_query($menu);
-
- echo '<select size=1 name="refSociete" class="textfield" onChange="if (this.selectedIndex!=0) window.location.href = this.options[this.selectedIndex].value;">'."\n";
- echo '<option value="0">Votre choix...</option>'."\n";
- while ($resultat = mysql_fetch_row($ReqLog)) {
- echo '<option value="afficher_contacts.php?refContact='.$resultat[0].'">'.$resultat[1];
- echo '</option>'."\n";
- }
- echo '</select>'."\n";
- ?>
-
- </td>
-
- </tr>
- <tr class="enteteblanc">
- <td colspan="3">
- <TABLE cellSpacing=0 cellPadding=0 border=0 width="100%"><TBODY>
- <TR>
- <TD bgColor=#3e4e6b>
- <TABLE cellSpacing=1 cellPadding=2 border=0 width="100%"><TBODY>
- <TR bgColor=#ffffff>
- <TD>
- <table cellSpacing=1 cellPadding=2 width="100%" border=0>
- <tr>
- <?php
- switch ($listing) {
- case "id-asc":
- $order = "refContact";
- break;
- case "firstname":
- $order = "prenom";
- break;
- case "firstname-desc":
- $order = "prenom DESC";
- break;
- case "lastname":
- $order = "nom";
- break;
- case "lastname-desc":
- $order = "nom DESC";
- break;
- default:
- $order = "refContact DESC";
- }
- ?>
- <td align=center class=entetebleue><a href="<?php echo "$PHP_SELF?listing=lastname"; ?>"><img src="images/ic_up.gif" border="0" alt=" Trier les noms --» A-B-C.." title=" Trier les noms --» A-B-C.."></a> Nom <a href="<?php echo "$PHP_SELF?listing=lastname-desc"; ?>"><img src="images/ic_down.gif" border="0" alt=" Trier les noms --» Z-X-Y.." title=" Trier les noms --» Z-X-Y.."></a></td>
- <td align=center class=entetebleue><a href="<?php echo "$PHP_SELF?listing=firstname"; ?>"><img src="images/ic_up.gif" border="0" alt=" Trier les noms --» A-B-C.." title=" Trier les noms --» A-B-C.."></a> Prenom <a href="<?php echo "$PHP_SELF?listing=firstname-desc"; ?>"><img src="images/ic_down.gif" border="0" alt=" Trier les noms --» Z-X-Y.." title=" Trier les noms --» Z-X-Y.."></a></td>
-
- <td align=center class=entetebleue>Téléphone Mobile </td>
- <td align=left class=entetebleue>Société</td>
- <td align=center colspan=2 class=entetebleue>Action</td>
- </tr>
- <?
- $ligne = 1;
- $result = mysql_query("select refContact, refSociete, nom, prenom, titre, telMobile, telBureau, telStandard, fax, email from tbl_contacts order by $order" );
- while ($row = mysql_fetch_object($result)) {
- $refSociete = $row->refSociete;
- $refContact = $row->refContact;
- $nom = $row->nom;
- $prenom = $row->prenom;
- $telMobile = $row->telMobile;
-
- ?>
- <tr>
- <td class=body align=center bgcolor="<? if ($ligne > 0) echo "ffffff"; else echo "dddddd"; ?>">
- <a href="afficher_contacts.php?refContact=<? echo $refContact ?>&nom=<? echo $nom ?>"><? echo $nom ?></a>
- </td>
- <td class=body align=center bgcolor="<? if ($ligne > 0) echo "ffffff"; else echo "dddddd"; ?>">
- <? echo $prenom ?>
- </td>
- <td class=body align=center bgcolor="<? if ($ligne > 0) echo "ffffff"; else echo "dddddd"; ?>">
- <? echo $telMobile ?>
- </td>
- <td class=body align=left bgcolor="<? if ($ligne > 0) echo "ffffff"; else echo "dddddd"; ?>">
- <? echo getNomSociete($refSociete) ?>
- </td>
- <td class=body align=center bgcolor="<? if ($ligne > 0) echo "ffffff"; else echo "dddddd"; ?>">
- [<a href="modification_contacts.php?refContact=<? echo $refContact ?>&nom=<? echo $nom ?>">Modifier</a>] [<a href="contactsDel.php?refContact=<? echo $refContact ?>&nom=<? echo $nom ?>" onClick="return conf();">Supprimer</a>]
- </td>
- </tr>
- <?
- $ligne = -$ligne;
- }
- mysql_free_result($result);
- ?>
- </table>
- </td>
- </tr>
- </TBODY></table>
- </td>
- </tr>
- </TBODY></table>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </TBODY></table>
- </td>
- </tr>
- <tr>
- <td align=center>
- </td>
- <td align=center class=body><br><br>[<a href="creation_contacts.php">Créer un nouveau Contact</a>]
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
-
- <?
- deconnecte($conn);
- ?>
- </body>
- </html>
|
|