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 :

Colorer une ligne sur deux dans un tableau selon le modèle trouvé dans la FAQ [MySQL]


Sujet :

PHP & Base de données

  1. #1
    Membre du Club
    Femme Profil pro
    piano
    Inscrit en
    Décembre 2011
    Messages
    131
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Suisse

    Informations professionnelles :
    Activité : piano
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Décembre 2011
    Messages : 131
    Points : 65
    Points
    65
    Par défaut Colorer une ligne sur deux dans un tableau selon le modèle trouvé dans la FAQ
    Bonjour,
    Dans la FAQ j'ai trouvé "Comment alterner la couleur des tr dans un tableau ?" malheureusement je n'arrive pas à l'utiliser

    mon tableau n'est pas colorisé et au-dessus j'ai un affichage de xxx fois

    "$couleur = ($compteur % 2 == 0) ? "#CCCCCC" : "#FFFFFF"; echo ''; $i++;"

    voici la partie de mon code concernée

    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
     
    .......................			
    $result = mysql_query($sql);
     
    if($result)
    {
    ?>
     
        <table border="1"  align="center">
     
            <tr>
                <th>Année</th>
                <th>Arrivée</th>
                <th>Départ</th>
    	    <th>Nb. jours</th>
    	    <th>Nom et prénom</th>
                <th>Prix Location</th>
                <th>Caution</th>
                <th>Lit bébé</th>
                <th>Linge</th>
                <th>Prix Total</th>																		
    	    <th>Somme payée</th>
                <th>Reste à payer</th>
    	    <th>Caution restituée</th>
    	</tr>
    <?php
     
    $i = 0;
     
            while($dateloca = mysql_fetch_assoc($result))
     
    {
    ?>
    $couleur = ($compteur % 2 == 0) ? "#CCCCCC" : "#FFFFFF";
      echo '<tr bgcolor="'.$couleur.'">
     
     
                    <td><b><big><font color="red"><?php display($dateloca['annee']); ?></font></big></b></td>
                    <td><?php display($dateloca['datea']); ?></td>
                    <td><?php display($dateloca['dated']); ?></td>								
                    <td><div class="alindr"><?php display($dateloca['datediff']); ?></div></td>								
                    <td><?php display($dateloca['nom'] . ' - ' .  $dateloca['prenom']); ?></td>
                    <td><div class="alindr"><?php display($dateloca['prixlocation']); ?></div></td>
                    <td><div class="alindr"><?php display($dateloca['caution']); ?></div></td>
                    <td><div class="alindr"><?php display($dateloca['litbaby']); ?></div></td>
                    <td><div class="alindr"><?php display($dateloca['linge']); ?></div></td>																								
                    <td><div class="alindr"><?php display($dateloca['PT']); ?></div></td>
                    <td><div class="alindr"><?php display($dateloca['Totalpaye']); ?></div></td>
                    <td><div class="alindr"><?php display($dateloca['Reste']); ?></div></td>																																								
                    <td><div class="alindr"><?php display($dateloca['restitution']); ?></div></td>
     
    </tr>';
     
    $i++;
    <?php
     
    }
    ?>
     
        </table>
    ................................
    j'ai certainement une erreur de syntaxe quelque part, j'ai essayé de déplacer mes balises mais c'est pire, je n'ai plus mon tableau, seulement une page blanche.

    D'avance merci pour votre aide toujours aussi précieuse

  2. #2
    Modérateur
    Avatar de Kreepz
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juin 2011
    Messages
    681
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 32
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Distribution

    Informations forums :
    Inscription : Juin 2011
    Messages : 681
    Points : 1 458
    Points
    1 458
    Billets dans le blog
    1
    Par défaut
    Bonjour,

    Effectivement tu as une erreur de syntaxe:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    <?php
     
    $i = 0;
     
            while($dateloca = mysql_fetch_assoc($result))
     
    {
    ?>
    $couleur = ($compteur % 2 == 0) ? "#CCCCCC" : "#FFFFFF";
      echo '<tr bgcolor="'.$couleur.'">

  3. #3
    Membre du Club
    Femme Profil pro
    piano
    Inscrit en
    Décembre 2011
    Messages
    131
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Suisse

    Informations professionnelles :
    Activité : piano
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Décembre 2011
    Messages : 131
    Points : 65
    Points
    65
    Par défaut
    ??? mais ??? c'est pareil, où est l'erreur ???
    Je ne comprends pas

    D'avance merci de m'aider si vous savez où est l'erreur.

    Bonne soirée

  4. #4
    Invité
    Invité(e)
    Par défaut
    Bonjour,
    1/ regarde justement la... couleur syntaxique du code :
    Il n'y aurait pas comme un ?> mal placé ?

    Plus bas aussi.

    2/ tu es sûre de comprendre ce que tu écris ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    $i = 0;
    ....
    $couleur = ($compteur % 2 == 0) ? "#CCCCCC" : "#FFFFFF";
    ....
    $i++
    $compteur ne risque pas de s'incrémenter...

    3/ Pour info, dans $compteur % 2, % est le modulo.
    Voir: Les opérateurs arithmétiques

  5. #5
    Membre du Club
    Femme Profil pro
    piano
    Inscrit en
    Décembre 2011
    Messages
    131
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Suisse

    Informations professionnelles :
    Activité : piano
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Décembre 2011
    Messages : 131
    Points : 65
    Points
    65
    Par défaut
    Bonjour,
    Merci de prendre la peine de me répondre, comme dit plus haut, j'ai trouvé dans la FAQ:
    "Comment alterner la couleur des tr dans un tableau ?"
    J'ai trouvé que c'était une bonne idée et j'ai voulu l'utiliser pour rendre mes tableaux plus lisibles, malheureusement je n'arrive pas à l'utiliser, en fait je ne sais pas bien où le mettre dans mon script qui lui fonctionne parfaitement, l'erreur est certainement due à l'endroit où sont ajoutées ces quelques lignes de code:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    $i = 0;
    while(condition) 
    {
      $couleur = ($compteur % 2 == 0) ? "#CCCCCC" : "#FFFFFF";
      echo '<tr bgcolor="'.$couleur.'"><td>texte</td></tr>';
      $i++;
    }
    mon code sans l'ajout des couleur:
    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
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
     
    <?php error_reporting ( E_ALL ); ?>
    <?php
    include("menu.php");
    ?>
    <link rel="stylesheet" href="style.css" type="text/css">
     
    <br/>
    <center>
    <?php
    echo '<input type="button" onclick="location.href=\''.( ( $variable == 1 ) ? 'listeloca.php' : 'listeloca.php' ).'\'" value="Recommencer" />';
    ?>
    </center>
    <br />
    <?php		
    function display($string)
    {
        echo htmlentities($string, ENT_QUOTES, 'ISO-8859-1');
    }
     
    include("include/variables.inc.php");
    	$liendb  =  mysql_connect($bddserver,  $bddlogin,  $bddpassword);
    mysql_select_db  ($bdd);
     
     
     
     
    $sql = "SELECT
    	DATE_FORMAT( datearrive, '%d/%m/%Y' ) AS datea,
    	DATE_FORMAT( datearrive, '%Y' ) AS annee,
    	DATE_FORMAT( datedepart, '%d/%m/%Y' ) AS dated,
    	DATEDIFF(datedepart,datearrive ) AS datediff,
    	dateloca.datearrive,
    	dateloca.datedepart,
    	dateloca.nombre,
    	dateloca.prixlocation,
    	dateloca.caution,
    	(dateloca.prixlocation+dateloca.caution+dateloca.linge+dateloca.litbaby) as PT,
            (dateloca.1erpaiement+dateloca.2epaiement+dateloca.3epaiement) as Totalpaye,
            (dateloca.prixlocation+dateloca.caution+dateloca.linge+dateloca.litbaby-dateloca.1erpaiement-dateloca.2epaiement-dateloca.3epaiement) as Reste,
    	(dateloca.1erpaiement+dateloca.2epaiement+dateloca.3epaiement-dateloca.caution) as Totalrevenu,
    	dateloca.1erpaiement,
    	DATE_FORMAT( date1erpaiement, '%d/%m/%Y' ) AS dateunp,
    	dateloca.2epaiement,
    	DATE_FORMAT( date2epaiement, '%d/%m/%Y' ) AS datedeuxp,
    	dateloca.3epaiement,
    	DATE_FORMAT( date3epaiement, '%d/%m/%Y' )	AS datetroisp,
    	dateloca.linge,
    	dateloca.litbaby,
    	dateloca.degatspayes,
    	dateloca.nonpaye,
    	dateloca.remarques,
    	dateloca.restitution,
    	DATE_FORMAT( datelettre, '%d/%m/%Y' ) AS datel,
    	dateloca.appart,
    	dateloca.envoitarifs,
    	dateloca.envoidescriptif,
    	dateloca.paragraphesup,
    	dateloca.confirmation,
    	dateloca.enfants,
    	locataires.nom,
    	locataires.prenom,
    	locataires.idnoms
    		FROM dateloca
    		INNER JOIN locataires ON  dateloca.idnoms = locataires.idnoms
    		JOIN (SELECT locataires.idnoms AS id_locataires, COUNT(*) AS total
    		FROM dateloca
    		INNER JOIN locataires ON  dateloca.idnoms = locataires.idnoms
    		WHERE locataires.reserve = 'oui' AND dateloca.annul =2 AND dateloca.prixlocation >0
    		GROUP BY locataires.idnoms
    		HAVING total>=2)
                    AS req_au_moins_2_locataires
    	        ON locataires.idnoms = req_au_moins_2_locataires. id_locataires
    		ORDER BY total desc, locataires.nom, datearrive desc;";
     
     
    $result = mysql_query($sql);
     
    if($result)
    {
    ?>
     
        <table border="1"  align="center">
     
            <tr>
                <th>Année</th>
                <th>Arrivée</th>
                <th>Départ</th>
    	    <th>Nb. jours</th>
    	    <th>Nom et prénom</th>
                <th>Prix Location</th>
                <th>Caution</th>
                <th>Lit bébé</th>
                <th>Linge</th>
                <th>Prix Total</th>																		
    	    <th>Somme payée</th>
                <th>Reste à payer</th>
    	    <th>Caution restituée</th>
    	</tr>
    <?php
     
            while($dateloca = mysql_fetch_assoc($result))
    {
    ?>
     
     
     
    <tr>
                    <td><b><big><font color="red"><?php display($dateloca['annee']); ?></font></big></b></td>
                    <td><?php display($dateloca['datea']); ?></td>
                    <td><?php display($dateloca['dated']); ?></td>								
                    <td><div class="alindr"><?php display($dateloca['datediff']); ?></div></td>								
                    <td><?php display($dateloca['nom'] . ' - ' .  $dateloca['prenom']); ?></td>
                    <td><div class="alindr"><?php display($dateloca['prixlocation']); ?></div></td>
                    <td><div class="alindr"><?php display($dateloca['caution']); ?></div></td>
                    <td><div class="alindr"><?php display($dateloca['litbaby']); ?></div></td>
                    <td><div class="alindr"><?php display($dateloca['linge']); ?></div></td>																								
                    <td><div class="alindr"><?php display($dateloca['PT']); ?></div></td>
                    <td><div class="alindr"><?php display($dateloca['Totalpaye']); ?></div></td>
                    <td><div class="alindr"><?php display($dateloca['Reste']); ?></div></td>																																								
                    <td><div class="alindr"><?php display($dateloca['restitution']); ?></div></td>
    <?php
     
    }
    ?>
     
        </table>
    <br />
    <br />
    <br />
    <br />
    <?php
    }
    mysql_close($liendb);
    ?>
    Et voici ce que j'ai fait et malheureusement cela ne marche pas, j'ai xxx fois :

    "$couleur = ($compteur % 2 == 0) ? "#CCCCCC" : "#FFFFFF"; echo ''; $i++;"

    qui s'affiche et mon tableau n'est pas coloré !!!

    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
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
     
    <?php error_reporting ( E_ALL ); ?>
    <?php
    include("menu.php");
    ?>
    <link rel="stylesheet" href="style.css" type="text/css">
     
    <br/>
    <center>
    <?php
    echo '<input type="button" onclick="location.href=\''.( ( $variable == 1 ) ? 'listeloca.php' : 'listeloca.php' ).'\'" value="Recommencer" />';
    ?>
    </center>
    <br />
    <?php		
    function display($string)
    {
        echo htmlentities($string, ENT_QUOTES, 'ISO-8859-1');
    }
     
    include("include/variables.inc.php");
    	$liendb  =  mysql_connect($bddserver,  $bddlogin,  $bddpassword);
    mysql_select_db  ($bdd);
     
    $sql = "SELECT
    	DATE_FORMAT( datearrive, '%d/%m/%Y' ) AS datea,
    	DATE_FORMAT( datearrive, '%Y' ) AS annee,
    	DATE_FORMAT( datedepart, '%d/%m/%Y' ) AS dated,
    	DATEDIFF(datedepart,datearrive ) AS datediff,
    	dateloca.datearrive,
    	dateloca.datedepart,
    	dateloca.nombre,
    	dateloca.prixlocation,
    	dateloca.caution,
    	(dateloca.prixlocation+dateloca.caution+dateloca.linge+dateloca.litbaby) as PT,
            (dateloca.1erpaiement+dateloca.2epaiement+dateloca.3epaiement) as Totalpaye,
            (dateloca.prixlocation+dateloca.caution+dateloca.linge+dateloca.litbaby-dateloca.1erpaiement-dateloca.2epaiement-dateloca.3epaiement) as Reste,
    	(dateloca.1erpaiement+dateloca.2epaiement+dateloca.3epaiement-dateloca.caution) as Totalrevenu,
    	dateloca.1erpaiement,
    	DATE_FORMAT( date1erpaiement, '%d/%m/%Y' ) AS dateunp,
    	dateloca.2epaiement,
    	DATE_FORMAT( date2epaiement, '%d/%m/%Y' ) AS datedeuxp,
    	dateloca.3epaiement,
    	DATE_FORMAT( date3epaiement, '%d/%m/%Y' )	AS datetroisp,
    	dateloca.linge,
    	dateloca.litbaby,
    	dateloca.degatspayes,
    	dateloca.nonpaye,
    	dateloca.remarques,
    	dateloca.restitution,
    	DATE_FORMAT( datelettre, '%d/%m/%Y' ) AS datel,
    	dateloca.appart,
    	dateloca.envoitarifs,
    	dateloca.envoidescriptif,
    	dateloca.paragraphesup,
    	dateloca.confirmation,
    	dateloca.enfants,
    	locataires.nom,
    	locataires.prenom,
    	locataires.idnoms
    		FROM dateloca
    		INNER JOIN locataires ON  dateloca.idnoms = locataires.idnoms
    		JOIN (SELECT locataires.idnoms AS id_locataires, COUNT(*) AS total
    		FROM dateloca
    		INNER JOIN locataires ON  dateloca.idnoms = locataires.idnoms
    		WHERE locataires.reserve = 'oui' AND dateloca.annul =2 AND dateloca.prixlocation >0
    		GROUP BY locataires.idnoms
    		HAVING total>=2)
                    AS req_au_moins_2_locataires
    	        ON locataires.idnoms = req_au_moins_2_locataires. id_locataires
    		ORDER BY total desc, locataires.nom, datearrive desc;";
     
    $result = mysql_query($sql);
     
    if($result)
    {
    ?>
     
        <table border="1"  align="center">
     
            <tr>
                <th>Année</th>
                <th>Arrivée</th>
                <th>Départ</th>
    	    <th>Nb. jours</th>
    	    <th>Nom et prénom</th>
                <th>Prix Location</th>
                <th>Caution</th>
                <th>Lit bébé</th>
                <th>Linge</th>
                <th>Prix Total</th>																		
    	    <th>Somme payée</th>
                <th>Reste à payer</th>
    	    <th>Caution restituée</th>
    	</tr>
    <?php
     
    $i = 0;
     
            while($dateloca = mysql_fetch_assoc($result))
     
    {
    ?>
    $couleur = ($compteur % 2 == 0) ? "#CCCCCC" : "#FFFFFF";
      echo '<tr bgcolor="'.$couleur.'">
     
                    <td><b><big><font color="red"><?php display($dateloca['annee']); ?></font></big></b></td>
                    <td><?php display($dateloca['datea']); ?></td>
                    <td><?php display($dateloca['dated']); ?></td>								
                    <td><div class="alindr"><?php display($dateloca['datediff']); ?></div></td>								
                    <td><?php display($dateloca['nom'] . ' - ' .  $dateloca['prenom']); ?></td>
                    <td><div class="alindr"><?php display($dateloca['prixlocation']); ?></div></td>
                    <td><div class="alindr"><?php display($dateloca['caution']); ?></div></td>
                    <td><div class="alindr"><?php display($dateloca['litbaby']); ?></div></td>
                    <td><div class="alindr"><?php display($dateloca['linge']); ?></div></td>																								
                    <td><div class="alindr"><?php display($dateloca['PT']); ?></div></td>
                    <td><div class="alindr"><?php display($dateloca['Totalpaye']); ?></div></td>
                    <td><div class="alindr"><?php display($dateloca['Reste']); ?></div></td>																																								
                    <td><div class="alindr"><?php display($dateloca['restitution']); ?></div></td>
     
    </tr>';
     
    $i++;
    <?php
     
    }
    ?>
     
        </table>
    <br />
    <br />
    <br />
    <br />
    <?php
    }
    mysql_close($liendb);
    ?>
    J'ai essayé de déplacer le mais alors j'ai une page blanche

    Merci d'avance et bon week-end

  6. #6
    Modérateur
    Avatar de Kreepz
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juin 2011
    Messages
    681
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 32
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Distribution

    Informations forums :
    Inscription : Juin 2011
    Messages : 681
    Points : 1 458
    Points
    1 458
    Billets dans le blog
    1
    Par défaut
    Cette partie est toujours fausse:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    <?php
     
    $i = 0;
     
            while($dateloca = mysql_fetch_assoc($result))
     
    {
    ?>
    $couleur = ($compteur % 2 == 0) ? "#CCCCCC" : "#FFFFFF";
      echo '<tr bgcolor="'.$couleur.'">
    Corrige le en:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    <?php
     
    $i = 0;
     
            while($dateloca = mysql_fetch_assoc($result))
     
    {
     
    $couleur = ($compteur % 2 == 0) ? "#CCCCCC" : "#FFFFFF";
      echo '<tr bgcolor="'.$couleur.'">
    
    ?>

  7. #7
    Membre du Club
    Femme Profil pro
    piano
    Inscrit en
    Décembre 2011
    Messages
    131
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Suisse

    Informations professionnelles :
    Activité : piano
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Décembre 2011
    Messages : 131
    Points : 65
    Points
    65
    Par défaut
    Merci, mais maintenant j'ai une page blanche

  8. #8
    Invité
    Invité(e)
    Par défaut
    Bonjour,
    comme je l'ai écrit dans mon précédent message (manifestement, on ne me lit pas... ) :
    entre $i et $compteur, il faut choisir !
    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    <?php
    $compteur = 0; // on initialise le COMPTEUR
    while($dateloca = mysql_fetch_assoc($result))
    {
            // on modifie la couleur de la ligne
            $couleur = ($compteur % 2 == 0) ? "#CCCCCC" : "#FFFFFF"; // on utilise le COMPTEUR !
    ?>
            <tr style="background-color:<?php echo $couleur; ?>;">
    .....
            </tr>
    <?php
            $compteur++; // on incrémente le COMPTEUR
    }
    ?>
    CELA DIT, il existe une AUTRE SOLUTION, en CSS !
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <table class="bicolor">
    et dans le CSS :
    Code css : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    table.bicolor tr:nth-child(even) {
       background-color:#CCCCCC;
    }
    table.bicolor tr:nth-child(odd) {
       background-color:#FFFFFF;
    }
    Simple et efficace.
    Dernière modification par Invité ; 14/03/2015 à 02h28.

  9. #9
    Membre du Club
    Femme Profil pro
    piano
    Inscrit en
    Décembre 2011
    Messages
    131
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Suisse

    Informations professionnelles :
    Activité : piano
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Décembre 2011
    Messages : 131
    Points : 65
    Points
    65
    Par défaut
    Encore une fois merci de prendre la peine de me répondre, j'ai essayé les deux solutions, j'ai mon tableau, pas de message d'erreur, mais ... pas de coloration .

    En ce qui concerne la solution CSS, j'utilise les CSS à d'autres endroits dans mon script et cela fonctionne, alors je ne comprends pas pourquoi là cela ne marche pas

    Merci d'avance et bon dimanche

  10. #10
    Invité
    Invité(e)
    Par défaut
    Tu as surement des erreurs ailleurs.

    Montres-nous TOUT le code de ta page.

  11. #11
    Membre du Club
    Femme Profil pro
    piano
    Inscrit en
    Décembre 2011
    Messages
    131
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Suisse

    Informations professionnelles :
    Activité : piano
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Décembre 2011
    Messages : 131
    Points : 65
    Points
    65
    Par défaut
    Pour tester plus facilement, j'ai fait un petit formulaire avec 4 tableaux de test, la coloration avec le CSS fonctionne, mas pas la dernière solution solution, malheureusement cela ne résout pas mon problème, voici ce qui fonctionne mais qui ne me sert à rien hélas

    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
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
     
    <link rel="stylesheet" href="style.css" type="text/css">
     
    <table class="bicolor" border="1"  align="center">
     
     
      <CAPTION> Voici le titre du tableau </CAPTION> 
      <TR> 
     <TH> Titre A1 </TH> 
     <TH> Titre A2 </TH> 
     <TH> Titre A3 </TH> 
     <TH> Titre A4 </TH> 
      </TR> 
      <TR> 
     <TH> Titre B1 </TH> 
     <TD> Valeur B2 </TD> 
     <TD> Valeur B3 </TD> 
     <TD> Valeur B4 </TD> 
      </TR> 
      <TR> 
     <TH> Titre C1 </TH> 
     <TD> Valeur C2 </TD> 
     <TD> Valeur C3 </TD> 
     <TD> Valeur C4 </TD> 
      </TR> 
     <TR> 
     <TH> Titre D1 </TH> 
     <TD> Valeur D2 </TD> 
     <TD> Valeur CD </TD> 
     <TD> Valeur D4 </TD> 
      </TR> 
     
    </TABLE> 
    <br>
    <br>
    <br>
    <br>
    <br>
    <table class="bicolor" border="1"  align="center">
    <tr> 
     <TH> Titre A1 </TH> 
    <td>texte1</td> 
    <td>texte2</td> 
    <td>texte3</td> 
    <td>texte4</td> 
    </tr> 
    <tr> 
     <TH> Titre B1 </TH> 
    <td>texte1</td> 
    <td>texte2</td> 
    <td>texte3</td> 
    <td>texte4</td> 
    </tr> 
    <tr> 
     <TH> Titre B1 </TH> 
    <td>texte1</td> 
    <td>texte2</td> 
    <td>texte3</td> 
    <td>texte4</td> 
    </tr> 
    <tr> 
     <TH> Titre B1 </TH> 
    <td>texte1</td> 
    <td>texte2</td> 
    <td>texte3</td> 
    <td>texte4</td> 
    </tr> 
    <tr> 
     <TH> Titre B1 </TH> 
    <td>texte1</td> 
    <td>texte2</td> 
    <td>texte3</td> 
    <td>texte4</td> 
    </tr> 
     
    </table> 
    <br>
    <br>
    <br>
    <br>
    <br>
     
    <table class="bicolor" border="1"  align="center">
              <CAPTION>Titre du tableau</CAPTION>
              <TR>
                 <TH>1re colonne</TH>  <TH>2me colonne</TH>  <TH>3me colonne</TH>
              </TR>
              <TR>
                 <TD>A</TD>  <TD>B</TD>  <TD>C</TD>
              </TR>
              <TR>
                 <TD>D</TD>  <TD>E</TD>  <TD>F</TD>
              </TR>
              <TR>
                 <TD>D</TD>  <TD>E</TD>  <TD>F</TD>
              </TR>
              <TR>
                 <TD>D</TD>  <TD>E</TD>  <TD>F</TD>
              </TR>
     
            </TABLE>
     
     
    <br>
    <br>
    <br>
    <br>
    <br>
     
     
     
    <?php
    $compteur = 0; // on initialise le COMPTEUR
     
    {
            // on modifie la couleur de la ligne
            $couleur = ($compteur % 2 == 0) ? "#CCCCCC" : "#FFFFFF"; // on utilise le COMPTEUR !
    ?>
    <table  border="1"  align="center">
            <tr style="background-color:<?php echo $couleur; ?>;">
     
    <tr> 
     <TH> Titre A1 </TH> 
    <td>texte1</td> 
    <td>texte2</td> 
    <td>texte3</td> 
    <td>texte4</td> 
    </tr> 
    <tr> 
     <TH> Titre B1 </TH> 
    <td>texte1</td> 
    <td>texte2</td> 
    <td>texte3</td> 
    <td>texte4</td> 
    </tr> 
    <tr> 
     <TH> Titre B1 </TH> 
    <td>texte1</td> 
    <td>texte2</td> 
    <td>texte3</td> 
    <td>texte4</td> 
    </tr> 
    <tr> 
     <TH> Titre B1 </TH> 
    <td>texte1</td> 
    <td>texte2</td> 
    <td>texte3</td> 
    <td>texte4</td> 
    </tr> 
    <tr> 
     <TH> Titre B1 </TH> 
    <td>texte1</td> 
    <td>texte2</td> 
    <td>texte3</td> 
    <td>texte4</td> 
    </tr> 
     
    </table> 
    <?php
            $compteur++; // on incrémente le COMPTEUR
    }
    ?>
     
        </table>
    Cela m'a permis de voir ce qui marche et ce qui ne marche pas, c'est en quelque sorte un progrès !!!

    Merci d'avance si vous pouvez encore m'aider

  12. #12
    Invité
    Invité(e)
    Par défaut
    1/ Qu'y a-t-il dans style.css ?

    2/ relis ton code.
    Commente chaque ligne.
    tu devrais voir que ce que tu as ecrit n'est pas logique (des lignes ne sont pas à la bonne place).

    N.B. tu avais juste à copier-coller mon code !!
    Encore faut-il savoir oú.....

    [Edit]
    Puisque la SOLUTION CSS fonctionne, pourquoi diable t'acharner avec l'autre ???

    le compteur suppose qu'on fait une boucle while.
    oú est-elle dans ton code ??

  13. #13
    Invité
    Invité(e)

  14. #14
    Invité
    Invité(e)
    Par défaut
    Voici ton code complet.
    Fais un simple copier-coller.
    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
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    <?php error_reporting ( E_ALL ); ?>
    <?php
    include("menu.php");
    ?>
    <link rel="stylesheet" href="style.css" type="text/css">
     
    <br/>
    <center>
    <?php
    echo '<input type="button" onclick="location.href=\''.( ( $variable == 1 ) ? 'listeloca.php' : 'listeloca.php' ).'\'" value="Recommencer" />';
    ?>
    </center>
    <br />
    <?php		
    function display($string)
    {
        echo htmlentities($string, ENT_QUOTES, 'ISO-8859-1');
    }
     
    include("include/variables.inc.php");
    	$liendb  =  mysql_connect($bddserver,  $bddlogin,  $bddpassword);
    mysql_select_db  ($bdd);
     
    $sql = "SELECT
    	DATE_FORMAT( datearrive, '%d/%m/%Y' ) AS datea,
    	DATE_FORMAT( datearrive, '%Y' ) AS annee,
    	DATE_FORMAT( datedepart, '%d/%m/%Y' ) AS dated,
    	DATEDIFF(datedepart,datearrive ) AS datediff,
    	dateloca.datearrive,
    	dateloca.datedepart,
    	dateloca.nombre,
    	dateloca.prixlocation,
    	dateloca.caution,
    	(dateloca.prixlocation+dateloca.caution+dateloca.linge+dateloca.litbaby) as PT,
            (dateloca.1erpaiement+dateloca.2epaiement+dateloca.3epaiement) as Totalpaye,
            (dateloca.prixlocation+dateloca.caution+dateloca.linge+dateloca.litbaby-dateloca.1erpaiement-dateloca.2epaiement-dateloca.3epaiement) as Reste,
    	(dateloca.1erpaiement+dateloca.2epaiement+dateloca.3epaiement-dateloca.caution) as Totalrevenu,
    	dateloca.1erpaiement,
    	DATE_FORMAT( date1erpaiement, '%d/%m/%Y' ) AS dateunp,
    	dateloca.2epaiement,
    	DATE_FORMAT( date2epaiement, '%d/%m/%Y' ) AS datedeuxp,
    	dateloca.3epaiement,
    	DATE_FORMAT( date3epaiement, '%d/%m/%Y' )	AS datetroisp,
    	dateloca.linge,
    	dateloca.litbaby,
    	dateloca.degatspayes,
    	dateloca.nonpaye,
    	dateloca.remarques,
    	dateloca.restitution,
    	DATE_FORMAT( datelettre, '%d/%m/%Y' ) AS datel,
    	dateloca.appart,
    	dateloca.envoitarifs,
    	dateloca.envoidescriptif,
    	dateloca.paragraphesup,
    	dateloca.confirmation,
    	dateloca.enfants,
    	locataires.nom,
    	locataires.prenom,
    	locataires.idnoms
    		FROM dateloca
    		INNER JOIN locataires ON  dateloca.idnoms = locataires.idnoms
    		JOIN (SELECT locataires.idnoms AS id_locataires, COUNT(*) AS total
    		FROM dateloca
    		INNER JOIN locataires ON  dateloca.idnoms = locataires.idnoms
    		WHERE locataires.reserve = 'oui' AND dateloca.annul =2 AND dateloca.prixlocation >0
    		GROUP BY locataires.idnoms
    		HAVING total>=2)
                    AS req_au_moins_2_locataires
    	        ON locataires.idnoms = req_au_moins_2_locataires. id_locataires
    		ORDER BY total desc, locataires.nom, datearrive desc;";
     
    $result = mysql_query($sql);
     
    if($result)
    {
    ?>
    	<table border="1"  align="center">
    	<thead>
    		<tr>
    			<th>Année</th>
    			<th>Arrivée</th>
    			<th>Départ</th>
    			<th>Nb. jours</th>
    			<th>Nom et prénom</th>
    			<th>Prix Location</th>
    			<th>Caution</th>
    			<th>Lit bébé</th>
    			<th>Linge</th>
    			<th>Prix Total</th>	
    			<th>Somme payée</th>
    			<th>Reste à payer</th>
    			<th>Caution restituée</th>
    		</tr>
    	<thead>
    	<tbody>
    <?php
    	$compteur = 0;
    	while($dateloca = mysql_fetch_assoc($result))
    	{
    		$couleur = ($compteur % 2 == 0) ? "#CCCCCC" : "#FFFFFF";
    		$compteur++;
    ?>
    		<tr style="background-color:'.$couleur.';">
    			<td><b><big><font color="red"><?php display($dateloca['annee']); ?></font></big></b></td>
    			<td><?php display($dateloca['datea']); ?></td>
    			<td><?php display($dateloca['dated']); ?></td>								
    			<td><div class="alindr"><?php display($dateloca['datediff']); ?></div></td>								
    			<td><?php display($dateloca['nom'] . ' - ' .  $dateloca['prenom']); ?></td>
    			<td><div class="alindr"><?php display($dateloca['prixlocation']); ?></div></td>
    			<td><div class="alindr"><?php display($dateloca['caution']); ?></div></td>
    			<td><div class="alindr"><?php display($dateloca['litbaby']); ?></div></td>
    			<td><div class="alindr"><?php display($dateloca['linge']); ?></div></td>																								
    			<td><div class="alindr"><?php display($dateloca['PT']); ?></div></td>
    			<td><div class="alindr"><?php display($dateloca['Totalpaye']); ?></div></td>
    			<td><div class="alindr"><?php display($dateloca['Reste']); ?></div></td>																																								
    			<td><div class="alindr"><?php display($dateloca['restitution']); ?></div></td>
    		</tr>
    <?php
    	} // fin while
    ?>
    	</tbody>
    	</table>
     
    <?php
    } // fin if
    // mysql_close($liendb); // cette ligne n est pas utile (la connexion se fermera automatiquement)
    ?>
    Essaie de le comprendre : structure de la table, position et logique des lignes de code...

    Il s'agit, depuis le début, d'une simple erreur d'inattention de ta part :
    TOUT le code PHP se met entre les balises <?php et ?>.

    [EDIT] Et quand tu auras 5 minutes, tu m'expliqueras l’intérêt et la logique de cette ligne :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    echo '<input type="button" onclick="location.href=\''.( ( $variable == 1 ) ? 'listeloca.php' : 'listeloca.php' ).'\'" value="Recommencer" />';
    'listeloca.php' : 'listeloca.php' : que la condition soit vraie ou fausse, on redirige vers la même page...

  15. #15
    Membre du Club
    Femme Profil pro
    piano
    Inscrit en
    Décembre 2011
    Messages
    131
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Suisse

    Informations professionnelles :
    Activité : piano
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Décembre 2011
    Messages : 131
    Points : 65
    Points
    65
    Par défaut
    Merci, c'est vraiment gentil de m'aider, c'est vrai qu'il y a eut des erreurs d'inattention, pourtant j'essaye de bien relire mes codes et de fermer les balises, mais comme disait ma grand-mère, "il n'y a que ceux qui ne font rien qui ne font pas d'erreurs" j'ai des livres, je lis des conseils et les faq, notamment sur ce forum, mais ce n'est pas mon métier, j'ai fait cette base de donnée et cette interface en PHP pour gérer la location d'un petit appartement de vacances, tout fonctionne, mais j'aimerais faire encore mieux, c'est pourquoi je cherche à colorer une ligne sur deux dans mes tableaux, même si ce n'est pas indispensable cela me permet d'apprendre et donc d'avancer, et je chercherai jusqu'à ce que j'y arrive, car je suis sur que c'est possible

    Mes explications n'étaient peut-être pas très claires, en effet la solution avec les CSS fonctionne dans le petit formulaire que j'ai fait pour tester, mais PAS si je le mets dans mon code.

    Bon, tu me demandes mon CSS, il est très simple, le voici:

    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
     
    BODY 
    {background:#D0D8D5; color:#01291A; font-family:Verdana; font-size:10px;}
     
    H1 
    {background:#ff6600; color:white; font-family:Arial; font-size:20px; font-weight:bold;}
     
    P 
    {background:#c60; color:white; font-family:Arial; font-size:14px; font-weight:bold;}
     
    table.bicolor tr:nth-child(even) {
       background-color:#CCCCCC;
    }
    table.bicolor tr:nth-child(odd) {
       background-color:#FFFFFF;
    }
     
    .centrer {
    margin-left : 100px;
    margin-right : 10px;
    text-align : center;
    color : #804000;
    }
     
    .boite1 {
    position : relative;
    padding : 10px;
    margin-top : 10px;
    margin-left : 200px;
    float : left;
    }
     
    .cleardiv {
    clear : both;
    height : 1em;
    }
     
    label
    {background:transparent; color:#3d081b; font-family:Arial; font-size:14px; font-weight:normal;}
     
     
    .cssbutton {
    background-color : #efeee8;
    border : 2px outset #98895f;
    padding : 1px 4px;
    color : #804000;
    text-decoration : none;
    font-size : small;
    }
    .cssbutton:visited {
    color : #804000;
    }
    .cssbutton:hover {
    border-style : inset;
    background-color : transparent;
    padding : 2px 3px 0 5px;
    /*padding : 1px 4px;*/
    }
    .cssbutton:active {
    color : #804000;
    }
     
     
    .alindr  {
    text-align: right;
    }

    concernant la ligne :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    echo '<input type="button" onclick="location.href=\''.( ( $variable == 1 ) ? 'listeloca.php' : 'listeloca.php' ).'\'" value="Recommencer" />';
    effectivement je n'avais pas besoin de répéter ce bouton "Recommencer" me permet de retourner à un autre formulaire depuis ce formulaire sans passer par mon menu.

    Comme tu me l'as conseillé j'ai fait un copier-coller du code, mais cela ne fonctionne pas mieux c'est désespérant !!!

    Encore une fois merci beaucoup pour la peine que tu prends à m'expliquer mes erreurs et pour ta patience.

  16. #16
    Invité
    Invité(e)
    Par défaut
    ! Oups ! mea culpa

    1/ Erreur d'inattention de MA part, cette fois :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    <?php
    	$compteur = 0;
    	while($dateloca = mysql_fetch_assoc($result))
    	{
    		$couleur = ($compteur % 2 == 0) ? "#CCCCCC" : "#FFFFFF";
    ?>
    		<tr style="background-color:<?php echo $couleur; ?>;">
    Mais, je le répète : le code en CSS est MIEUX.

    2/ au lieu de
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    echo '<input type="button" onclick="location.href=\''.( ( $variable == 1 ) ? 'listeloca.php' : 'listeloca.php' ).'\'" value="Recommencer" />';
    il suffit de mettre simplement:
    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    <a id="btretour" href="listeloca.php">Recommencer</a>
    et de styler le lien en CSS avec :

  17. #17
    Membre du Club
    Femme Profil pro
    piano
    Inscrit en
    Décembre 2011
    Messages
    131
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Suisse

    Informations professionnelles :
    Activité : piano
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Décembre 2011
    Messages : 131
    Points : 65
    Points
    65
    Par défaut
    Merci, je préfèrerais aussi utiliser le CSS mais ni l'un ni l'autre fonctionne dans mon code, cela fonctionne dans les petits tests que j'ai fait juste pour me rendre compte du résultat. Je me demande si le problème ne vient pas du fait que mon tableau est alimenté par une base de donnée, et non pas du genre:
    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
    <table class="bicolor" border="1"  align="center">
    <tr> 
     <TH> Titre A1 </TH> 
    <td>texte1</td> 
    <td>texte2</td> 
    <td>texte3</td> 
    <td>texte4</td> 
    </tr> 
    <tr> 
     <TH> Titre B1 </TH> 
    <td>texte1</td> 
    <td>texte2</td> 
    <td>texte3</td> 
    <td>texte4</td> 
    </tr> 
    <tr> 
     <TH> Titre B1 </TH> 
    <td>texte1</td> 
    <td>texte2</td> 
    <td>texte3</td> 
    <td>texte4</td> 
    </tr> 
    <tr> 
     <TH> Titre B1 </TH> 
    <td>texte1</td> 
    <td>texte2</td> 
    <td>texte3</td> 
    <td>texte4</td> 
    </tr> 
    <tr> 
     <TH> Titre B1 </TH> 
    <td>texte1</td> 
    <td>texte2</td> 
    <td>texte3</td> 
    <td>texte4</td> 
    </tr> 
     
    </table>
    qui fonctionne mais ne me sert à rien !!!!

    J'ai l'impression de tourner en rond

    Alors si tu as une autre idée, merci d'avance.

  18. #18
    Invité
    Invité(e)
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    	<table border="1"  align="center">
    Tu ne vois pas qu'il manque quelque chose, par rapport à ta page test ?

    au lieu de "tourner en rond", OUVRE LES YEUX .

  19. #19
    Membre du Club
    Femme Profil pro
    piano
    Inscrit en
    Décembre 2011
    Messages
    131
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Suisse

    Informations professionnelles :
    Activité : piano
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Décembre 2011
    Messages : 131
    Points : 65
    Points
    65
    Par défaut
    Merci, j'ai beau ouvrir les yeux, il ne manque rien !!! par rapport à ce que tu me dit, voici encore mon code qui fonctionne mais qui n'est pas coloré une ligne sur deux
    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
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
     
    <?php error_reporting ( E_ALL ); ?>
    <?php
    include("menu.php");
    ?>
    <link rel="stylesheet" href="style.css" type="text/css">
     
    <br/>
    <center>
    <?php
    <a id="btretour" href="listeloca.php">Recommencer</a>
    ?>
    </center>
    <br />
    <?php		
    function display($string)
    {
        echo htmlentities($string, ENT_QUOTES, 'ISO-8859-1');
    }
     
    include("include/variables.inc.php");
    	$liendb  =  mysql_connect($bddserver,  $bddlogin,  $bddpassword);
    mysql_select_db  ($bdd);
     
    $sql = "SELECT
    	DATE_FORMAT( datearrive, '%d/%m/%Y' ) AS datea,
    	DATE_FORMAT( datearrive, '%Y' ) AS annee,
    	DATE_FORMAT( datedepart, '%d/%m/%Y' ) AS dated,
    	DATEDIFF(datedepart,datearrive ) AS datediff,
    	dateloca.datearrive,
    	dateloca.datedepart,
    	dateloca.nombre,
    	dateloca.prixlocation,
    	dateloca.caution,
    	(dateloca.prixlocation+dateloca.caution+dateloca.linge+dateloca.litbaby) as PT,
            (dateloca.1erpaiement+dateloca.2epaiement+dateloca.3epaiement) as Totalpaye,
            (dateloca.prixlocation+dateloca.caution+dateloca.linge+dateloca.litbaby-dateloca.1erpaiement-dateloca.2epaiement-dateloca.3epaiement) as Reste,
    	(dateloca.1erpaiement+dateloca.2epaiement+dateloca.3epaiement-dateloca.caution) as Totalrevenu,
    	dateloca.1erpaiement,
    	DATE_FORMAT( date1erpaiement, '%d/%m/%Y' ) AS dateunp,
    	dateloca.2epaiement,
    	DATE_FORMAT( date2epaiement, '%d/%m/%Y' ) AS datedeuxp,
    	dateloca.3epaiement,
    	DATE_FORMAT( date3epaiement, '%d/%m/%Y' )	AS datetroisp,
    	dateloca.linge,
    	dateloca.litbaby,
    	dateloca.degatspayes,
    	dateloca.nonpaye,
    	dateloca.remarques,
    	dateloca.restitution,
    	DATE_FORMAT( datelettre, '%d/%m/%Y' ) AS datel,
    	dateloca.appart,
    	dateloca.envoitarifs,
    	dateloca.envoidescriptif,
    	dateloca.paragraphesup,
    	dateqloca.confirmation,
    	dateloca.enfants,
    	locataires.nom,
    	locataires.prenom,
    	locataires.idnoms
    		FROM dateloca
    		INNER JOIN locataires ON  dateloca.idnoms = locataires.idnoms
    		JOIN (SELECT locataires.idnoms AS id_locataires, COUNT(*) AS total
    		FROM dateloca
    		INNER JOIN locataires ON  dateloca.idnoms = locataires.idnoms
    		WHERE locataires.reserve = 'oui' AND dateloca.annul =2 AND dateloca.prixlocation >0
    		GROUP BY locataires.idnoms
    		HAVING total>=2)
                    AS req_au_moins_2_locataires
    	        ON locataires.idnoms = req_au_moins_2_locataires. id_locataires
    		ORDER BY total desc, locataires.nom, datearrive desc;";
     
    $result = mysql_query($sql);
     
    if($result)
    {
    ?>
    <table class="bicolor" border="1"  align="center">
     
            <tr>
                <th>Année</th>
                <th>Arrivée</th>
                <th>Départ</th>
    	    <th>Nb. jours</th>
    	    <th>Nom et prénom</th>
                <th>Prix Location</th>
                <th>Caution</th>
                <th>Lit bébé</th>
                <th>Linge</th>
                <th>Prix Total</th>																		
    	    <th>Somme payée</th>
                <th>Reste à payer</th>
    	    <th>Caution restituée</th>
    	</tr>
    <?php
     
            while($dateloca = mysql_fetch_assoc($result))
    {
    ?>
     
    <tr>
                    <td><?php display($dateloca['annee']); ?></td>
                    <td><?php display($dateloca['datea']); ?></td>
                    <td><?php display($dateloca['dated']); ?></td>								
                    <td><div class="alindr"><?php display($dateloca['datediff']); ?></div></td>								
                    <td><?php display($dateloca['nom'] . ' - ' .  $dateloca['prenom']); ?></td>
                    <td><div class="alindr"><?php display($dateloca['prixlocation']); ?></div></td>
                    <td><div class="alindr"><?php display($dateloca['caution']); ?></div></td>
                    <td><div class="alindr"><?php display($dateloca['litbaby']); ?></div></td>
                    <td><div class="alindr"><?php display($dateloca['linge']); ?></div></td>																								
                    <td><div class="alindr"><?php display($dateloca['PT']); ?></div></td>
                    <td><div class="alindr"><?php display($dateloca['Totalpaye']); ?></div></td>
                    <td><div class="alindr"><?php display($dateloca['Reste']); ?></div></td>																																								
                    <td><div class="alindr"><?php display($dateloca['restitution']); ?></div></td>
    </tr>
     
    <?php
     
    }
    ?>
     
    </table>
    </div>
    <br />
    <br />
    <br />
    <br />
    <?php
    }
    mysql_close($liendb);
    ?>
    J'ai modifié le bouton selon tes conseils.
    le petit formulaire avec le code qui colorise une ligne sur deux est celui-ci:

    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
    <table class="bicolor" border="1"  align="center">
    <tr> 
     <TH> Titre A1 </TH> 
    <td>texte1</td> 
    <td>texte2</td> 
    <td>texte3</td> 
    <td>texte4</td> 
    </tr> 
    <tr> 
     <TH> Titre B1 </TH> 
    <td>texte1</td> 
    <td>texte2</td> 
    <td>texte3</td> 
    <td>texte4</td> 
    </tr> 
    <tr> 
     <TH> Titre B1 </TH> 
    <td>texte1</td> 
    <td>texte2</td> 
    <td>texte3</td> 
    <td>texte4</td> 
    </tr> 
    <tr> 
     <TH> Titre B1 </TH> 
    <td>texte1</td> 
    <td>texte2</td> 
    <td>texte3</td> 
    <td>texte4</td> 
    </tr> 
    <tr> 
     <TH> Titre B1 </TH> 
    <td>texte1</td> 
    <td>texte2</td> 
    <td>texte3</td> 
    <td>texte4</td> 
    </tr> 
     
    </table>
    mais comme dit précédemment cela ne me sert à rien, c'est juste pour contrôler si le CSS fonctionne

    Merci de tout coeur pour la peine que tu te donnes pour m'aider

  20. #20
    Membre du Club
    Femme Profil pro
    piano
    Inscrit en
    Décembre 2011
    Messages
    131
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Suisse

    Informations professionnelles :
    Activité : piano
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Décembre 2011
    Messages : 131
    Points : 65
    Points
    65
    Par défaut


    J'ai trouvé !!!

    Dans mon script je fais appel à mon menu qui utilise son propre CSS. Il doit y avoir une incompatibilité entre les deux CSS.

    Si je retire l'appel au menu, j'ai les lignes de mon tableau colorées différemment pair/impair.

    Y a-t-il un moyen de rendre les deux CSS compatibles? Sans devoir modifier mon menu car il me donne entière satisfaction.

    Je ne marque pas cette discussion comme résolue puisqu'elle ne l'est pas complètement.

    Encore une fois merci d'avance pour votre patience et votre aide.


+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 2 12 DernièreDernière

Discussions similaires

  1. colorer une ligne sur deux dans une listbox
    Par Didpa dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 31/08/2010, 13h59
  2. Colorer une ligne sur deux d'un tableau
    Par mogz29 dans le forum Langage
    Réponses: 3
    Dernier message: 01/11/2009, 21h18
  3. Colorer une ligne sur deux dans plage de cellules
    Par JML62400 dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 15/02/2009, 19h48
  4. Colorer une ligne sur deux d'un crosstab
    Par zibou7 dans le forum iReport
    Réponses: 0
    Dernier message: 26/11/2008, 16h26
  5. Colorer une ligne sur deux dans un tableau croisé
    Par markoBasa dans le forum iReport
    Réponses: 1
    Dernier message: 25/09/2008, 11h15

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