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 :

Problème entete de tableau


Sujet :

PHP & Base de données

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Juin 2011
    Messages
    59
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juin 2011
    Messages : 59
    Par défaut Problème entete de tableau
    Bonjour voila mon problème j'ai fait un petit site qui fait que lorsque l'on clique sur un des bouton ou que l'on lance une recherche cela m'affiche mes résultats dans un tableau mais là problème les entêtes se répète a chaque résultat. Voici le 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
     
    <? 
    if (mysql_num_rows($mysql_result) > 0){
     
    while($row=mysql_fetch_array($mysql_result))
    {
    ?>
     
     
     
     
     
    <body bgcolor="white">
    <table width="100%" border="1" bordercolor="#900" cellpadding="0" cellspacing="0" bgcolor="white" align="center">
      <!--DWLayoutTable-->
      <tr>
        <th width="15%" height="23"></th>
        <th width="20%">Marque</th>
        <th width="30%">Modele/Energie</th>
        <th width="8%">Prix</th>
        <th width="10%">Km</th>
        <th width="8%">Année</th>
        <th width="7%">Plus</th>
      </tr>
      <tr>
        <td width="166" rowspan="6"  valign="middle"><table width="100%" border="1">
          <tr>
            <td valign="top"><font size="3" face="Comic Sans MS"><a href="<? print($row["photo"]);?>"><img src="<? print($row["photo"]);?>" width="77" height="55" border="1" alt="" align="center" /></a></font></td>
            <td><font size="3" face="Comic Sans MS"><a href="<? print($row["photo1"]);?>"><img src="<? print($row["photo1"]);?>" width="77" height="55" border="1" alt="" align="center"/></a></font></td>
          </tr>
          <tr>
            <td><font size="3" face="Comic Sans MS"><a href="<? print($row["photo3"]);?>"><img src="<? print($row["photo3"]);?>" width="77" height="55" border="1" alt="" align="center"/></a></font></td>
            <td><font size="3" face="Comic Sans MS"><a href="<? print($row["photo2"]);?>"><img src="<? print($row["photo2"]);?>" width="77" height="55" border="1" alt="" align="center" /></a></font></td>
          </tr>
        </table></td>
        <td height="155" align="center"><h5>Marque : <? print($row["marque"]);?></h5>
        <h5><a href="mailto:garage-bujon-blessac@wanadoo.fr?subject=Réservation du véhicule de marque<? print($row["marque"]);?>&nbsp;Modèle : <? print($row["modele"]);?>&nbsp;Prix: <? print($row["prix"]);?>euros&body=Merci d'inscrire vos coordonnées dans ce mail">Réservez ce véhicule</a></h5></td>
        <td height="155" align="center"><p>Modèle: <? print($row["modele"]);?></p>
        <p>Energie:<? print($row["carburant"]);?></p></td>
        <td height="155" align="center"><? print($row["prix"]);?> &euro;</td>
        <td height="155" align="center"><? print($row["kilometre"]);?></td>
        <td height="155" align="center"><? print($row["misecircu"]);?> </td>
        <td align="center"><a href="fiche.php?sel=<? print($row["id"]);?>" target="_blank"><strong><em><font size="-1">Voir la fiche véhicule</font></em></strong></a><br /></td>
      </tr>
    </table>
    <?
     
    }  
    }
    else {
    	echo '<body bgcolor="white" text="black">';
    	echo "<h5 align='center'>Désolé, il n'y a aucun véhicule correspondant à vôtre demande</h5>";
    	}
    ?>
    </body>
    </html>
    Ce que j'aimerais c'est qu'il n'y ait qu'une seule entête pour tout les résultats pour alléger l'affichage d'une et parce que j'ai l'intention de rendre les entêtes cliquable pour effectuer des tris.J'ai essayer différentes façon pour mes entêtes comme mettre les entete avant le while pour pas quel se répéte mais j'obtiens un magnifique escalier avec mes images(que j'ai mis dans un second tableau pr facilter l'alignement et l'affichage peut etre que c'est ce qui m'empeche de faire ce que je veux non?).
    Merci d'avance

  2. #2
    Membre averti Avatar de Thibault92
    Homme Profil pro
    Étudiant
    Inscrit en
    Juin 2011
    Messages
    45
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2011
    Messages : 45
    Par défaut
    Sort l'entete de ton tableau de ta boucle

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    <!--DWLayoutTable-->
      <tr>
        <th width="15%" height="23"></th>
        <th width="20%">Marque</th>
        <th width="30%">Modele/Energie</th>
        <th width="8%">Prix</th>
        <th width="10%">Km</th>
        <th width="8%">Année</th>
        <th width="7%">Plus</th>
      </tr>
    => tu le mets au dessus de ton while($row=mysql_fetch_array($mysql_result))

  3. #3
    Membre averti Avatar de Thibault92
    Homme Profil pro
    Étudiant
    Inscrit en
    Juin 2011
    Messages
    45
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2011
    Messages : 45
    Par défaut
    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
    <? 
    if (mysql_num_rows($mysql_result) > 0){
    ?>
    <body bgcolor="white">
    <table width="100%" border="1" bordercolor="#900" cellpadding="0" cellspacing="0" bgcolor="white" align="center">
      <!--DWLayoutTable-->
      <tr>
        <th width="15%" height="23"></th>
        <th width="20%">Marque</th>
        <th width="30%">Modele/Energie</th>
        <th width="8%">Prix</th>
        <th width="10%">Km</th>
        <th width="8%">Année</th>
        <th width="7%">Plus</th>
      </tr>
    <? 
    while($row=mysql_fetch_array($mysql_result))
    {
    ?>
      <tr>
        <td width="166" rowspan="6"  valign="middle"><table width="100%" border="1">
          <tr>
            <td valign="top"><font size="3" face="Comic Sans MS"><a href="<? print($row["photo"]);?>"><img src="<? print($row["photo"]);?>" width="77" height="55" border="1" alt="" align="center" /></a></font></td>
            <td><font size="3" face="Comic Sans MS"><a href="<? print($row["photo1"]);?>"><img src="<? print($row["photo1"]);?>" width="77" height="55" border="1" alt="" align="center"/></a></font></td>
          </tr>
          <tr>
            <td><font size="3" face="Comic Sans MS"><a href="<? print($row["photo3"]);?>"><img src="<? print($row["photo3"]);?>" width="77" height="55" border="1" alt="" align="center"/></a></font></td>
            <td><font size="3" face="Comic Sans MS"><a href="<? print($row["photo2"]);?>"><img src="<? print($row["photo2"]);?>" width="77" height="55" border="1" alt="" align="center" /></a></font></td>
          </tr>
        </table></td>
        <td height="155" align="center"><h5>Marque : <? print($row["marque"]);?></h5>
        <h5><a href="mailto:garage-bujon-blessac@wanadoo.fr?subject=Réservation du véhicule de marque<? print($row["marque"]);?>&nbsp;Modèle : <? print($row["modele"]);?>&nbsp;Prix: <? print($row["prix"]);?>euros&body=Merci d'inscrire vos coordonnées dans ce mail">Réservez ce véhicule</a></h5></td>
        <td height="155" align="center"><p>Modèle: <? print($row["modele"]);?></p>
        <p>Energie:<? print($row["carburant"]);?></p></td>
        <td height="155" align="center"><? print($row["prix"]);?> &euro;</td>
        <td height="155" align="center"><? print($row["kilometre"]);?></td>
        <td height="155" align="center"><? print($row["misecircu"]);?> </td>
        <td align="center"><a href="fiche.php?sel=<? print($row["id"]);?>" target="_blank"><strong><em><font size="-1">Voir la fiche véhicule</font></em></strong></a><br /></td>
      </tr>
    </table>
    <?
     
    }  
    }
    else {
    	echo '<body bgcolor="white" text="black">';
    	echo "<h5 align='center'>Désolé, il n'y a aucun véhicule correspondant à vôtre demande</h5>";
    	}
    ?>
    </body>
    </html>

  4. #4
    Expert confirmé
    Avatar de Benjamin Delespierre
    Profil pro
    Développeur Web
    Inscrit en
    Février 2010
    Messages
    3 929
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Février 2010
    Messages : 3 929
    Par défaut
    Voici un exemple de construction de tableau HTML avec PHP et les résultats d'une requête MySQL.
    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
    <table>
    	<caption>Un Titre</caption>
    	<thead>
    		<tr>
    			<td>Col1</td>
    			<td>Col2</td>
    			<td>Col3</td>
    		</tr>
    	</thead>
    	<tfoot>
    		<!-- Mettre un footer si nécéssaire -->
    	</tfoot>
    	<tbody>
    		<?php while ($row = mysql_fetch_assoc($results)): ?>
    		<tr>
    			<td><?=$row['col1']?></td>
    			<td><?=$row['col2']?></td>
    			<td><?=$row['col3']?></td>
    		</tr>
    		<?php endwhile ?>
    	</tbody>
    </table>
    Pour que ton tableau soit triable, le mieux est d'utiliser le plugin jquery tablesorter.

  5. #5
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Juin 2011
    Messages
    59
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juin 2011
    Messages : 59
    Par défaut
    Wha merci je viens juste de me rebranché je m'attendais pas à des réponse aussi rapise!Je vais étudier tout ça merci!

  6. #6
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Juin 2011
    Messages
    59
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juin 2011
    Messages : 59
    Par défaut
    C'est bon ca marche en revanche le table sorter heu c'est pas un peu évolué (dur) pour un débutant étant donné que le jquery j'en ai jamais fait et que le javascript je débute à peine?

  7. #7
    Expert confirmé
    Avatar de Benjamin Delespierre
    Profil pro
    Développeur Web
    Inscrit en
    Février 2010
    Messages
    3 929
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Février 2010
    Messages : 3 929
    Par défaut
    C'est pas bien compliqué, il suffit d'ajouter les scipts jquery et tablesorter dans le head puis de faire:
    Code HTML : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    <script type="text/javascript">
    $(function () {
      // remplacer 'id' par l'id de ta table
      $('table#id').tablesorter();
    });
    </script>

    On peut difficilement rêver plus simple

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

Discussions similaires

  1. Problème avec un tableau et saut de ligne
    Par ero-sennin dans le forum Balisage (X)HTML et validation W3C
    Réponses: 6
    Dernier message: 08/03/2006, 18h48
  2. Problème avec un tableau de tableau
    Par SubZero2 dans le forum Langage
    Réponses: 4
    Dernier message: 07/12/2005, 15h25
  3. problème avec un tableau dans un insert ...
    Par vbcasimir dans le forum Langage
    Réponses: 3
    Dernier message: 02/11/2005, 14h31
  4. [PERL] problème tri de tableau
    Par LE NEINDRE dans le forum Langage
    Réponses: 2
    Dernier message: 31/08/2005, 15h42
  5. [HTML/CSS] problème bordure de tableau
    Par LE NEINDRE dans le forum Mise en page CSS
    Réponses: 2
    Dernier message: 18/08/2005, 11h42

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