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 :

Passage d'arguments avec la méthode GET


Sujet :

PHP & Base de données

  1. #1
    Membre régulier
    Inscrit en
    Décembre 2008
    Messages
    319
    Détails du profil
    Informations forums :
    Inscription : Décembre 2008
    Messages : 319
    Points : 89
    Points
    89
    Par défaut Passage d'arguments avec la méthode GET
    Bonjour,

    je ne comprends pas je sais que je souhaite afficher mes labels selon la premeire lettre du label j ai un buton.php ave cun menu qui pointe vers un fichier label.php qui utilise la fonction GET celui ci doit recuperer dans l url le mot "lettre" afin d afficher les bonnes entrées selon le menu selectionner je sais que je dois mettre "label.php?lettre=a" "label.php?lettre=b" ... dans mes liens dans mon m,eu mais la focntion include me gene je ne peux pas le faire.... j espere que vous comprenez car je ne sais aps si je suis claire

    voic le bouton.php

    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
    <!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="bouton.php?page=label" target="_self" class="active"><span>Label 0-
     
    9</span></a></li>
      <li><a href="bouton.php?page=label" target="_self"><span>Label A</span></a></li>
      <li><a href="bouton.php?page=label" target="_self"><span>Label B</span></a></li>
      <li><a href="bouton.php?page=label" target="_self"><span>Label C</span></a></li>
      <li><a href="bouton.php?page=label" target="_self"><span>Label D</span></a></li>
      <li><a href="bouton.php?page=label" target="_self"><span>Label E</span></a></li>
      <li><a href="bouton.php?page=label" target="_self"><span>Label F</span></a></li>
      <li><a href="bouton.php?page=label" target="_self"><span>Label G</span></a></li>
      <li><a href="bouton.php?page=label" target="_self"><span>Label H</span></a></li>
      <li><a href="bouton.php?page=label" target="_self"><span>Label I</span></a></li>
      <li><a href="bouton.php?page=label" target="_self"><span>Label J</span></a></li>
      <li><a href="bouton.php?page=label" target="_self"><span>Label K</span></a></li>
      <li><a href="bouton.php?page=label" target="_self"><span>Label L</span></a></li>
      <li><a href="bouton.php?page=label" target="_self"><span>Label M</span></a></li>
      <li><a href="bouton.php?page=label" target="_self"><span>Label N</span></a></li>
      <li><a href="bouton.php?page=label" target="_self"><span>Label O</span></a></li>
      <li><a href="bouton.php?page=label" target="_self"><span>Label P</span></a></li>
      <li><a href="bouton.php?page=label" target="_self"><span>Label Q</span></a></li>
      <li><a href="bouton.php?page=label" target="_self"><span>Label R</span></a></li>
      <li><a href="bouton.php?page=label" target="_self"><span>Label S</span></a></li>
      <li><a href="bouton.php?page=label" target="_self"><span>Label T</span></a></li>
      <li><a href="bouton.php?page=label" target="_self"><span>Label U</span></a></li>
      <li><a href="bouton.php?page=label" target="_self"><span>Label V</span></a></li>
      <li><a href="bouton.php?page=label" target="_self"><span>Label W</span></a></li>
      <li><a href="bouton.php?page=label" target="_self"><span>Label X</span></a></li>
      <li><a href="bouton.php?page=label" target="_self"><span>Label Y</span></a></li>
      <li><<a href="bouton.php?page=label" target="_self"><span>Label Z</span></a></li>
     
     
     
    <?php
    		if(!empty($_GET['page']))
    		{
    			if(file_exists($_GET['page'].'.php') AND !preg_match("/
    
    (\.|config|inc)/iU", $_GET['page']))
    			{
    				include ($_GET['page'].'.php');
    			}
     
     
    		}
     
    		?>
     
     
     
    </ul>
    </body>
    </html>
    et voici le label.php

    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
    <!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/
    xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
    <head>
    <meta http-equiv="content-type"
    content="text/html; charset=iso-8859-1" />
    <title></title>
    <link rel="stylesheet" type="text/css" href="style.css" />
    </head>
    <body>
     
    <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 du Club
    Inscrit en
    Octobre 2008
    Messages
    62
    Détails du profil
    Informations forums :
    Inscription : Octobre 2008
    Messages : 62
    Points : 48
    Points
    48
    Par défaut
    Remplacer :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <li><a href="bouton.php?page=label" target="_self"><span>Label A</span></a></li>
    par

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <li><a href="label.php?lettre=A" target="_self"><span>Label A</span></a></li>
    pour tous les liens (B, C, D etc...)

  3. #3
    Membre régulier
    Inscrit en
    Décembre 2008
    Messages
    319
    Détails du profil
    Informations forums :
    Inscription : Décembre 2008
    Messages : 319
    Points : 89
    Points
    89
    Par défaut
    merci nico il prend bine les label de la lettre a mais mon include ne fonctione plus j ai moidife le "page" par "lettre" mais il s affiche maintenant sur une autre page ...

    voila le bout de code qui pose problème :

    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
     
    <?php
    		if(!empty($_GET['lettre']))
    		{
    			if(file_exists($_GET['lettre'].'.php') AND !preg_match("/
    
    (\.|config|inc)/iU", $_GET['lettre']))
    			{
    				include ($_GET['lettre'].'.php');
    			}
     
     
    		}
     
    		?>

  4. #4
    Membre du Club
    Inscrit en
    Octobre 2008
    Messages
    62
    Détails du profil
    Informations forums :
    Inscription : Octobre 2008
    Messages : 62
    Points : 48
    Points
    48
    Par défaut
    Je ne sais pas ce que tu veux faire avec ton include.

    Mais sur le principe, tu n'en as plus besoin.
    Tu es sur ta page bouton.php. L'utilisateur clique sur "Label A" par exemple. La page label.php?lettre=A s'ouvre. Cette page récupère la valeur de "lettre", fait la requête en fonction de la lettre (ici "A") et t'affiche les résultats.

    A moins que tu veuilles faire quelque chose que je n'ai pas compris, tu peux retirer :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    if(!empty($_GET['lettre']))
    		{
    			if(file_exists($_GET['lettre'].'.php') AND !preg_match("/
     
    (\.|config|inc)/iU", $_GET['lettre']))
    			{
    				include ($_GET['lettre'].'.php');
    			}
     
     
    		}
    de bouton.php

  5. #5
    Membre régulier
    Inscrit en
    Décembre 2008
    Messages
    319
    Détails du profil
    Informations forums :
    Inscription : Décembre 2008
    Messages : 319
    Points : 89
    Points
    89
    Par défaut
    en fait cette include me pemrettait d afficher le resultat de ma requete dans la meme page que le bouton.php avec le menu en haut et le tableu en bas sans ouvrir une autre page

  6. #6
    Membre du Club
    Inscrit en
    Octobre 2008
    Messages
    62
    Détails du profil
    Informations forums :
    Inscription : Octobre 2008
    Messages : 62
    Points : 48
    Points
    48
    Par défaut
    A ce moment là tu fais tout dans la même page.
    Admettons tu fais tout dans index.php :
    . tu crées tes boutons qui renvoient vers index.php?lettre=xx,
    . tu testes si $_GET["lettre"] existe,
    . si ça existe tu fais ta requête et tu affiches tes résultats

Discussions similaires

  1. [AJAX] Passage de 2 paramètres avec la méthode GET
    Par furth dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 01/06/2007, 16h18
  2. Réponses: 3
    Dernier message: 09/02/2007, 22h39
  3. Passage de données via la méthode GET
    Par xaaros dans le forum Langage
    Réponses: 9
    Dernier message: 09/11/2006, 10h32
  4. Réponses: 8
    Dernier message: 01/06/2006, 11h14
  5. [VBA-E] passage d'argument avec la méthode "Show"
    Par JOUBERT dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 14/03/2006, 13h56

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