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] Affichage de données horizontale


Sujet :

Langage PHP

  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Juin 2005
    Messages
    487
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Juin 2005
    Messages : 487
    Par défaut [Tableaux] Affichage de données horizontale
    Bonjour,

    Je fais afficher les réponses d'un sondage une en dessous de l'autre mais j'aimerais afficher de cette façon:


    Réponses des sondages
    Question 1 2 3 4
    1-Ponctualité
    2-Langage
    3-Horaire
    4-Tenue
    5-Ecoute
    etc.

    Il y a plusieurs questions et le nombre de sondage peut varier.

    Actuellement, j'Affiche ainsi:
    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
    while ($donnees = mysql_fetch_array($reponse) )
    	{
    	echo "<p align='center'><h2><strong>Sondage no : </strong>".$nb_sond."</h2></p>";
    ?>
    	<table align="center" width="90%" cellpadding="3" border="1">
    		<tr align="center">
    			<td width="60%" align="center"><strong>Question</strong></td>
    			<td width="5%" align="center"><strong>Rép.</strong></td>
    			<td width="35%" align="center"><strong>Commentaire</strong></td>
    		</tr>	 
    		<tr>
    			<td><strong>Ponctualité</strong></td>	
          <td align="center"><?php echo $donnees['e_ponctualite']; ?></td>
    			<td><?php echo $donnees['pon_note']; ?></td>	
    		</tr>
    						<tr>
    							<td><strong>Dynamiste</strong></td>					
    							<td align="center"><?php echo $donnees['e_dynamiste']; ?></td>
    							<td><?php echo $donnees['dyn_note']; ?></td>	
    						</tr>
    						<tr>

  2. #2
    Membre expérimenté Avatar de frol
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    288
    Détails du profil
    Informations personnelles :
    Âge : 36
    Localisation : Belgique

    Informations forums :
    Inscription : Mars 2005
    Messages : 288
    Par défaut
    un peu du mal a comprendre ce que tu veux
    fais nous un tableau comme tu veux et on t'aidra a le dynamiser

  3. #3
    Membre éclairé
    Profil pro
    Inscrit en
    Juin 2005
    Messages
    487
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Juin 2005
    Messages : 487
    Par défaut
    Les questions sont dans la première colonne et les réponses des sondages dans la 2e, 3e, 4e colonne etc.

  4. #4
    Membre expérimenté Avatar de frol
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    288
    Détails du profil
    Informations personnelles :
    Âge : 36
    Localisation : Belgique

    Informations forums :
    Inscription : Mars 2005
    Messages : 288
    Par défaut
    Je verrais bien quelque chose comme ceci

    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
    //on enregistre les données dans un array
    $i = 0;
    while ($donnees = mysql_fetch_array($reponse) ){
         $j = 0;
         foreach($donnees as $donnee){
            $data[$j][$i] = $donnee;
            $j++;
         }
         $i++;
    }
     
     
    //on fait le tableau
    echo '<table>';
            .'<tr>'
            .'   <td>Questions</td>'
            .'   <td>1</td>'
            .'   <td>2</td>'
            .'   <td>3</td>'
            .'   <td>4</td>'
            .'   <td>5</td>'
            .'   <td>6</td>'                                        
            .'</tr>';
            .'<tr>'
            .'   <td>Titre</td>';
    foreach($data[0] as $value) echo '<td>'.$value.'</td>';
     
    echo    '</tr>'
            .'<tr>'
            .'   <td>Titre</td>';
    foreach($data[1] as $value) echo '<td>'.$value.'</td>';
     
    echo    '</tr>'
            ...
        .'</table>';

  5. #5
    Membre éclairé
    Profil pro
    Inscrit en
    Juin 2005
    Messages
    487
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Juin 2005
    Messages : 487
    Par défaut
    Merci de ta réponse, je savais que je me dirigeais vers les tableaux que je ne maitrise pas.

    J'ai regardé le tout et les résultats du sondage ne s'affiche. Dans la table, il y a 8 sondages et c'Est exactement le nombre de colonnes.

    Voici le lien pour voir: http://www.ats3r.org/script/sondage/ent_sond2.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
    <?php
    mysql_select_db("ATS"); // Sélection de la base de données
    $reponse = mysql_query("SELECT * FROM `ATS_sondage` ORDER BY id") or die(mysql_error());
    $nb_sond=1;
    $i = 0;
    while ($donnees = mysql_fetch_array($reponse) ){
         $j = 0;
         foreach($donnees as $donnee){
            $data[$j][$i] = $donnee;
            $j++;
         }
         $i++;
    }
     
    //on fait le tableau
    echo '<table border="1">';
            '.<tr>'
            .'   <td>Question</td>'
            .'   <td>1</td>'
            .'   <td>2</td>'
            .'   <td>3</td>'
            .'   <td>4</td>'
            .'   <td>5</td>'
            .'   <td>6</td>'                                        
            .'</tr>';
    echo    '<tr>'
            .'   <td>Titre</td>';
    foreach($data[0] as $value) echo '<td>'.$value.'</td>';
     
    echo    '</tr>'
            .'<tr>'
            .'   <td>Titre</td>';
    foreach($data[1] as $value) echo '<td>'.$value.'</td>';
     
    echo    '</tr>'
        .'</table>';
     
    ?>

  6. #6
    Membre expérimenté Avatar de frol
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    288
    Détails du profil
    Informations personnelles :
    Âge : 36
    Localisation : Belgique

    Informations forums :
    Inscription : Mars 2005
    Messages : 288
    Par défaut
    pourrais tu nous donner le schéma exact de ta base?

    Merci

  7. #7
    Membre éclairé
    Profil pro
    Inscrit en
    Juin 2005
    Messages
    487
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Juin 2005
    Messages : 487
    Par défaut
    int(11) Non
    ip varchar(50) Non
    saison varchar(5) Non
    categorie varchar(5) Non
    niveau varchar(5) Non
    entraineur varchar(60) Non
    passeport varchar(7) Non
    ats_inscription tinyint(1) Non 0
    inc_note varchar(255) Non
    ats_evaluation tinyint(1) Non 0
    eva_note varchar(255) Non
    ats_equipe tinyint(1) Non 0
    for_note varchar(255) Non
    ats_cout tinyint(1) Non 0
    cout_note varchar(255) Non
    ats_qualite tinyint(1) Non 0
    qua_note varchar(255) Non
    ats_web tinyint(1) Non 0
    web_note varchar(255) Non
    ats_heure tinyint(1) Non 0
    hre_note varchar(255) Non
    ats_appel tinyint(1) Non 0
    app_note varchar(255) Non
    ats_note text Non
    t_vu char(3) Non 0
    t_connaissance char(3) Non 0
    t_note text Non
    t_supervision tinyint(1) Non 0
    t_espoir tinyint(1) Non 0
    t_evaluation tinyint(1) Non 0
    t_formation tinyint(1) Non 0
    t_plainte tinyint(1) Non 0
    t_note2 text Non
    s_gilet char(3) Non 0
    s_liste char(3) Non 0
    s_impliquer char(3) Non 0
    s_retour char(3) Non 0
    s_hiver char(3) Non 0
    s_cld char(3) Non 0
    s_note text Non
    e_ponctualite tinyint(1) Non 0
    pon_note varchar(150) Non
    e_dynamiste tinyint(1) Non 0
    dyn_note varchar(150) Non
    e_entrainement tinyint(1) Non 0
    ent_note varchar(150) Non
    e_respect tinyint(1) Non 0
    resp_note varchar(150) Non
    e_ecoute tinyint(1) Non 0
    eco_note varchar(150) Non
    e_pratique tinyint(1) Non 0
    pp_note varchar(150) Non
    e_partie tinyint(1) Non 0
    par_note varchar(150) Non
    e_connaissance tinyint(1) Non 0
    con_note varchar(150) Non
    e_langue tinyint(1) Non 0
    lan_note varchar(150) Non
    e_tenue tinyint(1) Non 0
    ten_note varchar(150) Non
    e_horaire tinyint(1) Non 0
    hor_note varchar(150) Non
    e_arbitre tinyint(1) Non 0
    arb_note varchar(150) Non
    e_ecart tinyint(1) Non 0
    eca_note varchar(150) Non
    e_staff tinyint(1) Non 0
    staf_note varchar(150) Non
    e_ats tinyint(1) Non 0
    dig_note varchar(150) Non
    e_impact tinyint(1) Non 0
    imp_note varchar(150) Non
    e_retour tinyint(1) Non 0
    ret_note varchar(150) Non
    e_note text Non
    e_esprit char(3) Non 0
    e_apprecie char(3) Non 0
    e_division char(3) Non 0
    e_info char(3) Non 0
    e_pts char(3) Non 0
    e_serie char(3) Non 0
    e_note2 text Non
    ef_pedagogie char(3) Non 0
    ef_technique char(3) Non 0
    ef_psychologie char(3) Non 0
    ef_militaire char(3) Non 0
    ef_relaxation char(3) Non 0
    ef_aucune char(3) Non 0
    ef_note text Non
    maj date Non 000

  8. #8
    Membre éclairé
    Profil pro
    Inscrit en
    Juin 2005
    Messages
    487
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Juin 2005
    Messages : 487
    Par défaut
    Dans l'exécution, je constate que mes données dont en double.

Discussions similaires

  1. Réponses: 2
    Dernier message: 15/12/2006, 11h31
  2. Réponses: 2
    Dernier message: 28/11/2006, 12h20
  3. [Tableaux] affichage des données d'une base
    Par Nickwell dans le forum Langage
    Réponses: 1
    Dernier message: 29/09/2006, 18h14
  4. [Tableaux] affichage de donnée
    Par moons dans le forum Langage
    Réponses: 4
    Dernier message: 08/02/2006, 15h59
  5. [Tableaux] Affichage des données par lot
    Par randriarabe dans le forum Langage
    Réponses: 1
    Dernier message: 07/12/2005, 09h23

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