IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PHP & Base de données Discussion :

Trier données en commencant par chiffre


Sujet :

PHP & Base de données

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Inscrit en
    Décembre 2008
    Messages
    319
    Détails du profil
    Informations forums :
    Inscription : Décembre 2008
    Messages : 319
    Par défaut Trier données en commencant par chiffre
    Bonjour,

    j ai fichier php qui m affiche un menu avec un tableau résultat d un select entre deux tables tout fonctionne super sauf que pour que le résultat s affiche dans la page et par première lettre label a, label b ... j ai mis un get me permettant d afficher les label par première lettre, mon souci est que je veux afficher également ceux commençant par un chiffre mais quand je mets 0, 1 ou 2 ca fonctionne mais comment faire en sorte qu il prenne tous les chiffres de 0 à 9 ?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN"
    "http://www.w3.org/TR/xhtmll/DTD/xhtmll-transitional.dtd">
    <html Xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>listing</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
     
     
     
     
     
     
     
    <ul class="menu">
      <li><a href="label.php?lettre='2%'"  class="active"><span>Label 0-9</span></a></li>
      <li><a href="label.php?lettre=A" target="_self"><span>Label A</span></a></li>
      <li><a href="label.php?lettre=B" target="_self"><span>Label B</span></a></li>
      <li><a href="label.php?lettre=C" target="_self"><span>Label C</span></a></li>
      <li><a href="label.php?lettre=D" target="_self"><span>Label D</span></a></li>
      <li><a href="label.php?lettre=E" target="_self"><span>Label E</span></a></li>
      <li><a href="label.php?lettre=F" target="_self"><span>Label F</span></a></li>
      <li><a href="label.php?lettre=G" target="_self"><span>Label G</span></a></li>
      <li><a href="label.php?lettre=H" target="_self"><span>Label H</span></a></li>
      <li><a href="label.php?lettre=I" target="_self"><span>Label I</span></a></li>
      <li><a href="label.php?lettre=J" target="_self"><span>Label J</span></a></li>
      <li><a href="label.php?lettre=K" target="_self"><span>Label K</span></a></li>
      <li><a href="label.php?lettre=L" target="_self"><span>Label L</span></a></li>
      <li><a href="label.php?lettre=M" target="_self"><span>Label M</span></a></li>
      <li><a href="label.php?lettre=N" target="_self"><span>Label N</span></a></li>
      <li><a href="label.php?lettre=o" target="_self"><span>Label O</span></a></li>
      <li><a href="label.php?lettre=P" target="_self"><span>Label P</span></a></li>
      <li><a href="label.php?lettre=Q" target="_self"><span>Label Q</span></a></li>
      <li><a href="label.php?lettre=R" target="_self"><span>Label R</span></a></li>
      <li><a href="label.php?lettre=S" target="_self"><span>Label S</span></a></li>
      <li><a href="label.php?lettre=T" target="_self"><span>Label T</span></a></li>
      <li><a href="label.php?lettre=U" target="_self"><span>Label U</span></a></li>
      <li><a href="label.php?lettre=V" target="_self"><span>Label V</span></a></li>
      <li><a href="label.php?lettre=W" target="_self"><span>Label W</span></a></li>
      <li><a href="label.php?lettre=X" target="_self"><span>Label X</span></a></li>
      <li><a href="label.php?lettre=Y" target="_self"><span>Label Y</span></a></li>
      <li><<a href="label.php?lettre=Z" target="_self"><span>Label Z</span></a></li>
     
     
     
    <br></br>
    <br></br>
    <br></br>
    <br></br>
    <br></br>
     
    <?php
     
    include ('config.php');
    include ('connexion.php');
     
    echo '<table>
    
    <tr>
    
    <th>Label</th>
    <th>Référence</th>
    <th>Artiste</th>
    <th>Album</th>
    <th>Format</th>
    <th>Modifier</th>
    <th>Supprimer</th>
    
    </tr>';
     
    //  paramètre reçu désignant le critère du nom du label recherché
    $param1 = ($_GET['lettre']);
     
     
    //
    $sql = "SELECT * FROM label
    INNER JOIN contenu ON contenu.id_label = label.id_label
    Where nom_label LIKE '$param1%' order by nom_label, reference;
    ";
    $req = mysql_query($sql);
    while ($resultat = mysql_fetch_array($req))
     
     
    {
    echo '<tr>';
     
     
    echo '<td>'.$resultat['nom_label'].'</td>';
    echo '<td>'.$resultat['reference'].'</td>';
    echo '<td>'.$resultat['artiste'].'</td>';
    echo '<td>'.$resultat['album'].'</td>';
    echo '<td>'.$resultat['format'].'</td>';
    echo '<td><a href="formulaire_de_mise_a_jour.php?reference='.$resultat
     
    ['reference'].'">Modifier</a></td>';
    echo '<td><a href="script_de_suppression.php?reference='.$resultat
     
    ['reference'].'">Supprimer</a></td>'; 
     
     
     
     
     
    echo '</tr>';
    }
     
    echo '</table>';
     
    ?>
     
    </body></html>
     
    <?php
    mysql_close();
    ?>

  2. #2
    Membre éclairé
    Inscrit en
    Décembre 2008
    Messages
    319
    Détails du profil
    Informations forums :
    Inscription : Décembre 2008
    Messages : 319
    Par défaut
    up

Discussions similaires

  1. Réponses: 1
    Dernier message: 29/03/2013, 16h49
  2. [MySQL] selection de produits commencant par 2 chiffres
    Par freija dans le forum Langage SQL
    Réponses: 7
    Dernier message: 04/08/2006, 10h34
  3. Trier données dans formulaire par checkbox
    Par Sofie109 dans le forum Access
    Réponses: 9
    Dernier message: 27/07/2006, 08h56
  4. Réponses: 3
    Dernier message: 11/01/2006, 20h44
  5. Rechercher les occurences commencant par un chiffre
    Par tony slayer dans le forum Requêtes
    Réponses: 2
    Dernier message: 25/05/2005, 14h48

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo