$query...order by$order
nathanael76
Messages postés
17
Statut
Membre
-
nathanael76 Messages postés 17 Statut Membre -
nathanael76 Messages postés 17 Statut Membre -
Bonjour,
J'aimerai que l'utilisateur puisse choisir le champs d'une table pour la trier en fonction.
Voici ce que j'ai qui ne marche pas :
<table>
<tr>
<th colspan="3">Nom</th></tr>
<tr>
<th>Url</th>
<th>Sigle</th>
<th>E-mail</th>
</tr>
<?php
echo"
<a href=\participants-test1.php?order=url\>order url</a>";
echo"
<a href=\participants-test1.php?order=nom\>order nom</a>";
$host = "..." ;
$user = ...;
$bdd = ... ;
$passwd = ...;
mysql_connect($host, $user,$passwd) or die("erreur de connexion au serveur");
if(isset($_GET['order']))$order=$GET['order'];
mysql_select_db($bdd) or die("erreur de connexion a la base de donnees");
$query = "SELECT * FROM participants ORDER BY '$order'";
$result = mysql_query($query);
while($row = mysql_fetch_row($result)){
$url = $row[0];
$nom = $row[3];
$sigle = $row[2];
$email = $row[26];
echo
"<table>
<tr>\n
<td.nom> <a href=\"$nom\"> $nom </a> </td.nom> \n
<tr>\n
<td.url> <a href=\"$url\"> $url </a> </td.url> \n
<tr>
<td.sigle><a href=\"$sigle\"> $sigle </a> </td.sigle>\n
<td.email><a href=\"$email\"> $email </a> </td.email>\n
</tr>\n";
}
mysql_close();
?>
</table>
et voici le résultat :
http://www.solidaritok.com/participants-test1.php
en vous remerciant, amicalement, Guy.
J'aimerai que l'utilisateur puisse choisir le champs d'une table pour la trier en fonction.
Voici ce que j'ai qui ne marche pas :
<table>
<tr>
<th colspan="3">Nom</th></tr>
<tr>
<th>Url</th>
<th>Sigle</th>
<th>E-mail</th>
</tr>
<?php
echo"
<a href=\participants-test1.php?order=url\>order url</a>";
echo"
<a href=\participants-test1.php?order=nom\>order nom</a>";
$host = "..." ;
$user = ...;
$bdd = ... ;
$passwd = ...;
mysql_connect($host, $user,$passwd) or die("erreur de connexion au serveur");
if(isset($_GET['order']))$order=$GET['order'];
mysql_select_db($bdd) or die("erreur de connexion a la base de donnees");
$query = "SELECT * FROM participants ORDER BY '$order'";
$result = mysql_query($query);
while($row = mysql_fetch_row($result)){
$url = $row[0];
$nom = $row[3];
$sigle = $row[2];
$email = $row[26];
echo
"<table>
<tr>\n
<td.nom> <a href=\"$nom\"> $nom </a> </td.nom> \n
<tr>\n
<td.url> <a href=\"$url\"> $url </a> </td.url> \n
<tr>
<td.sigle><a href=\"$sigle\"> $sigle </a> </td.sigle>\n
<td.email><a href=\"$email\"> $email </a> </td.email>\n
</tr>\n";
}
mysql_close();
?>
</table>
et voici le résultat :
http://www.solidaritok.com/participants-test1.php
en vous remerciant, amicalement, Guy.
A voir également:
- $query...order by$order
- Power query download - Télécharger - Tableur
- Gunnm last order scan ✓ - Forum Réseaux sociaux
- By click downloader avis - Forum Enregistrement / Traitement audio
- Shoes by iara - Forum Consommation & Internet
- By click downloader ne fonctionne plus - Forum Enregistrement / Traitement audio
1 réponse
Salut,
tu as un problème lorsque tu affiches les liens qui permettrait de lancer les tris.
Ton code :
Ce qui peut-être fonctionnerait mieux :
A+, crabs
tu as un problème lorsque tu affiches les liens qui permettrait de lancer les tris.
Ton code :
echo" <a href=\participants-test1.php?order=url\>order url</a>"; echo" <a href=\participants-test1.php?order=nom\>order nom</a>";
Ce qui peut-être fonctionnerait mieux :
echo "<a href=\"participants-test1.php?order=url\">order url</a>"; echo "<a href=\"participants-test1.php?order=nom\">order nom</a>";
A+, crabs
Amicalement.