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

Langage PHP Discussion :

[Tableaux] Problème de récupération de valeur [Débutant(e)]


Sujet :

Langage PHP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    77
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 77
    Par défaut [Tableaux] Problème de récupération de valeur
    Bonjour,
    je fais afficher une liste allant de la lettre A à Z d'après laquelle le récupère une liste d'objet.Lorsque cette liste est vide je veut faire apparaitre un message me disant qu'il n'y a aucun objet pour cette lettre.
    Je récupère toujours la dernière lettre qui est le Z.
    Comment faire pour récupèrer les autres valeurs.

    Voici mon code
    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
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Document sans titre</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link rel="stylesheet" type="text/css" href="../MisePage12.css"/>
    <body>
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td colspan="3" class="L1"><p>Liste des DVD  </p>
        <p>Nombres total de DVD : <?php echo $totalRows_RsListeDVD ?> </p></td>
      </tr>
      <tr class="L2">
        <td class="L2C1"></td>
        <td class="L2C2">
          <div id="navcontainer">
    		<ul id="navlist">
    		<li id="active"><a href="Index.php" id="current">Accueil</a></li>
    		<li><a href="ConsulterListeDVD.php">DVD</a></li>
    		<li><a href="connexion.php" style="color:#FF0000">Connexion</a></li>
    		</ul>
    </div></td>
        <td class="L2C3BIS"></td>
      </tr>
      <tr class="L3">
        <td class="L3C1">&nbsp;</td>
        <td class="L3C2"><table width="100%"  border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="30px" class="Message"><?php if ($totalRows_RsListeDVD == 0 ) {echo "Pas de DVD dans la Médiathèque" ; 
    }
    		else{
    		 $ID='0'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp</a>' ;
    		 $ID='1'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp;</a>' ; 
    		 $ID='2'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp</a>' ;
    		 $ID='3'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp;</a>' ; 
    		 $ID='4'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp</a>' ;
    		 $ID='5'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp;</a>' ; 
    		 $ID='6'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp</a>' ;
    		 $ID='7'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp;</a>' ; 
    		 $ID='8'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp</a>' ;
    		 $ID='9'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp;</a>' ; 
    		 $ID='A'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp;</a>' ; 
    		 $ID='B'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp</a>' ;
    		 $ID='C'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp;</a>' ; 
    		 $ID='D'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp</a>' ;
    		 $ID='E'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp;</a>' ; 
    		 $ID='F'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp</a>' ;
    		 $ID='G'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp;</a>' ; 
    		 $ID='H'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp</a>' ;
    		 $ID='I'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp;</a>' ; 
    		 $ID='J'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp</a>' ;
    		 $ID='K'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp;</a>' ; 
    		 $ID='L'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp</a>' ;
    		 $ID='M'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp;</a>' ; 
    		 $ID='N'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp</a>' ;
    		 $ID='O'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp;</a>' ; 
    		 $ID='P'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp</a>' ;
    		 $ID='Q'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp;</a>' ; 
    		 $ID='R'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp</a>' ;
    		 $ID='S'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp;</a>' ; 
    		 $ID='T'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp;</a>' ; 
    		 $ID='U'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp;</a>' ; 
    		 $ID='V'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp</a>' ;
    		 $ID='W'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp;</a>' ; 
    		 $ID='X'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp</a>' ;
    		 $ID='Y'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp;</a>' ; 
    		 $ID='Z'; echo '<a href="ConsulterListeDVD.php?TitreID='.$ID.'">'.$ID.'&nbsp</a>' ;
    }?></td>
      </tr>
      <tr>
        <td height="526px" align="center">      
    	<table border="0" cellpadding="0" cellspacing="0" width="700">
          <?php do { ?>
          <tr>
            <td><div align="center">
                <?php if ($totalRows_RsListeDVD != 0 ) {
    				if ($totalRows_RsRecherche == 0 ) {
    				echo "Pas de DVD commen&ccedil;ant par la lettre : $ID" ; 
    				}
    			 else {
    			$ID=$row_RsRecherche['FldIdref'];  
    			echo '<a href="ConsulterDVD.php?TitreID='.$ID.'">'.$row_RsRecherche['FldTitre'].'</a>'; 
    			}
    			}?>
            </div></td>
          </tr>
          <?php } while ($row_RsRecherche = mysql_fetch_assoc($RsRecherche)); ?>
        </table></td>
      </tr>
    Merci

  2. #2
    Membre chevronné
    Profil pro
    Inscrit en
    Août 2006
    Messages
    379
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 379
    Par défaut
    Tu n'aurais pas meilleur temps de ne pas afficher la lettre quand il n'y a pas de résultat ?

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    77
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 77
    Par défaut
    Cela me parait plus compliquer a réaliser

  4. #4
    Membre chevronné
    Profil pro
    Inscrit en
    Août 2006
    Messages
    379
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 379
    Par défaut
    Tes données sont stockés dans une BDD, tu pourrais me montrer la structure de cette dernière ?

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    77
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 77
    Par défaut
    Voila structure de ma table DVD en Pièce joint
    Merci
    Images attachées Images attachées  

  6. #6
    Membre chevronné
    Profil pro
    Inscrit en
    Août 2006
    Messages
    379
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 379
    Par défaut
    Essaye ça :
    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
    <?php
     
    $r = mysql_query('SELECT FldIdref, FldTitre FROM tbldvd ORDER BY FldTitre ASC');
    $lettre = '';
    while($b = mysql_fetch_array($r)) {
    	$first = $b['FldTitre']{0};
     
            $c .= '<a href="ConsulterListeDVD.php?TitreID='.$b['FldIdref'].'">'.$b['FldTitre'].'</a><br />';
     
    	if ($lettre != $first) {
               $lettre = $first;
         	   $txt .= '<b>'.htmlspecialchars($lettre).'</b><br />';
            }
    	$txt .= $c;
    	unset($c);
    }
     
    ?>
    Il te suffit de faire un echo de $txt pour que ta liste s'affiche.

    Bonne journée.

  7. #7
    Membre confirmé
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    77
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 77
    Par défaut
    J'obtient une erreur dans cette ligne
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $c .= '<a href="ConsulterListeDVD.php?TitreID='.$b['FldIdref'].'">'.$b['FldTitre']'</a><br />';
    le Echo je le mais a la suite

  8. #8
    Membre chevronné
    Profil pro
    Inscrit en
    Août 2006
    Messages
    379
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 379
    Par défaut
    Ah oki, et bien désolé

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 1
    Dernier message: 10/07/2006, 13h40
  2. [SQL] Problème de récupération des valeurs d'une liste multiple en php
    Par BOLARD dans le forum PHP & Base de données
    Réponses: 1
    Dernier message: 01/05/2006, 00h29
  3. Problème de récupération de valeurs
    Par T'chab dans le forum Access
    Réponses: 3
    Dernier message: 24/04/2006, 10h37
  4. Problème de récupération de valeur de radio button...
    Par Empty_body dans le forum Général JavaScript
    Réponses: 4
    Dernier message: 08/03/2006, 14h19
  5. Nouveau problème de récupération de valeurs.
    Par pmboutteau dans le forum ASP
    Réponses: 4
    Dernier message: 09/03/2005, 10h48

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