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 :

Donner une couleur à une valeur/Texte en PHP


Sujet :

PHP & Base de données

  1. #1
    Futur Membre du Club
    Femme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Mars 2023
    Messages
    10
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 22
    Localisation : France, Corse (Corse)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Mars 2023
    Messages : 10
    Points : 8
    Points
    8
    Par défaut Donner une couleur à une valeur/Texte en PHP
    Bonjour , Tout le monde je tiens à vous remercier tout d'abord pour le temps que vous consacré en lisant mon problème

    mon code et le suivant chaque $publisher[] affiche du texte mon souci et le suivant :

    ce <td>" . $publisher['statut'] . "</td> Affiche soit la lettre A ou bien P mon souci et de faire en sorte que si la lettre et A elle doit être en couleur Rouge affiché en PHP

    merci infiniment
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $Resultat .= "<tr><td>" . $publisher['IDEmployePointages'] . "</td><td>" . $publisher['NomCompletEmployes'] . "</td><td>" . $publisher['LibelleDepartement'] . "</td><td>" . $publisher['LibelleService'] . "</td><td>" . $publisher['DatePointages'] . "</td><td>" . $publisher['HeurPointages'] . "</td><td>" . $publisher['salle'] . "</td><td>" . $publisher['statut'] . "</td><td>" . $publisher['seances'] . "</td></tr>";

  2. #2
    Expert éminent
    Avatar de Séb.
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    5 237
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mars 2005
    Messages : 5 237
    Points : 8 501
    Points
    8 501
    Billets dans le blog
    17
    Par défaut
    ce <td>" . $publisher['statut'] . "</td> Affiche soit la lettre A ou bien P mon souci et de faire en sorte que si la lettre et A elle doit être en couleur Rouge affiché en PHP
    Il y a plein de manières de faire, avec des CSS dans le conteneur :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    <td style="color: <?= $publisher['statut'] === 'A' ? 'red' : 'inherit' ?>">
        <?= $publisher['statut'] ?>
    </td>

  3. #3
    Futur Membre du Club
    Femme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Mars 2023
    Messages
    10
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 22
    Localisation : France, Corse (Corse)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Mars 2023
    Messages : 10
    Points : 8
    Points
    8
    Par défaut
    Citation Envoyé par Séb. Voir le message
    Il y a plein de manières de faire, avec des CSS dans le conteneur :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    <td style="color: <?= $publisher['statut'] === 'A' ? 'red' : 'inherit' ?>">
        <?= $publisher['statut'] ?>
    </td>
    bonjour Monsieur ci-joint l'erreur que j'ai recu en utilisant votre code

    Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\xampp\htdocs\ismagip\control\F_ShowPointage.php on line 117

  4. #4
    Expert éminent
    Avatar de Séb.
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    5 237
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mars 2005
    Messages : 5 237
    Points : 8 501
    Points
    8 501
    Billets dans le blog
    17
    Par défaut
    Le code que j'ai communiqué ne peut pas produire ce genre d'erreur.

  5. #5
    Futur Membre du Club
    Femme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Mars 2023
    Messages
    10
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 22
    Localisation : France, Corse (Corse)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Mars 2023
    Messages : 10
    Points : 8
    Points
    8
    Par défaut
    Pour plus d'éclairement monsieur voilà le code entier avec la modification du code que vous m'avez suggérer juste en bas du code

    N.B : c'est un message Echo

    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
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
     <?php
     
    include 'F_Connection.php';
    include('../zklib/ZKLib.php');
     
    //debut de la session
    session_name('ZKTeco');
    session_start();
     
    $conn = OpenCon();
     
    $myIniFile = parse_ini_file("../ini/Config.ini", TRUE);
    $host = $myIniFile["pointeurse"]["adr"];
    $zk = new ZKLib($host, 4370);
    $DateFrom = null;
    $DateTo = null;
     
    //recuperation des valeurs
    $IDDep = $_GET['Dep'] ?? "";
    $IDSer = $_GET['Ser'] ?? "";
    $IDEmp = $_GET['Emp'] ?? "";
    $IDSea = $_GET['Sea'] ?? "";
    $TxtIDDep = $_GET['DepTxt'] ?? "";
    $TxtIDSer = $_GET['SerTxt'] ?? "";
    $TxtIDEmp = $_GET['EmpTxt'] ?? "";
    $TxtIDSea = $_GET["SeaTxt"] ?? "";
    if ($_GET['DateFrom'] ?? "") {
        $DateFrom = new DateTime($_GET['DateFrom'] ?? "");
    }
    if ($_GET['DateTo'] ?? "") {
        $DateTo = new DateTime($_GET['DateTo'] ?? "");
    }
    $DayDiff = $_GET['DayDiff'] ?? "";
     
    $SqlRecherche = null;
    $Resultat = "";
    $diff = null;
     
     
     
    if (!empty($DateFrom) && !empty($DateTo)) {
        if ($IDEmp == 'T') {
            $SqlRecherche = "SELECT DISTINCT * FROM Employes,Service,Departement,Affectation,xhistorique WHERE Service.IDService=Affectation.IDService AND Employes.IDEmployes=xhistorique.IDEmployePointages AND Service.IDDepartement=Departement.IDDepartement AND Employes.UIDEmployes=Affectation.IDEmployes AND ActiveEmp!=0 AND Service.IDService=".$IDSer." AND Departement.IDDepartement=".$IDDep." AND xhistorique.seances=".$TxtIDSea." AND xhistorique.DatePointages BETWEEN '".$DateFrom->format('Y-m-d')."' AND '".$DateTo->format('Y-m-d')."' ";
        } else {
            $SqlRecherche = "SELECT DISTINCT * FROM Employes,Service,Departement,Affectation,xhistorique WHERE Service.IDService=Affectation.IDService AND Employes.IDEmployes=xhistorique.IDEmployePointages AND Service.IDDepartement=Departement.IDDepartement AND Employes.UIDEmployes=Affectation.IDEmployes AND ActiveEmp!=0 AND Service.IDService=".$IDSer." AND Departement.IDDepartement=".$IDDep." AND Employes.IDEmployes=".$IDEmp." AND xhistorique.seances=:".$TxtIDSea." AND xhistorique.DatePointages BETWEEN '".$DateFrom->format('Y-m-d')."' AND '".$DateTo->format('Y-m-d')."'";
        }
     
        //echo $SqlRecherche."<br/>";
        echo '<div class="card border-left-success shadow h-50 py-2">
            <div class="card-body">
                <div class="row no-gutters align-items-center">
                    <div class="col mr-2">
                        <div class="text-xs font-weight-bold text-success text-uppercase mb-1">Recherche
                        </div>
                        <div class="row no-gutters align-items-center"> Département : <b>' . $TxtIDDep . '</b> - Filière : <b>' . $TxtIDSer . '</b> - Employée : <b>' . $TxtIDEmp . '</b> <b> - Seances : <b>' . $TxtIDSea . '</b> |  De : <b>' . $DateFrom->format('Y-m-d') . '</b> - A : <b>' . $DateTo->format('Y-m-d') . '</b> - Totale Jours : ' . $DayDiff . '</div>
                    </div>
                    <div class="col-auto">
                        <i class="fas fa-search fa-2x text-red-300"></i>
                    </div>
                </div>
            </div>
        </div>';
        $Resultat .= "<table class='table table-bordered' id='dataTable' width='100%' cellspacing='0'>
    <thead>
        <tr>
            <th>Matricule</th>
            <th>Nom</th>
            <!--th>N° Card</th!-->
            <th>Département</th>
            <th>Filière</th>
            <!--th>Pointage</th!-->
            <th>Date</th>
            <th>Heure</th>
            <!--th>Type</th!-->
            <th>Salle</th>
            <th>Statut</th>
            <th>Seances</th>
        </tr>
    </thead>
    <tbody >";
     
     
        $statement = $conn->query($SqlRecherche);
        $publishers = $statement->fetchAll(PDO::FETCH_ASSOC);
     
        if ($publishers) {
     
     
     
     
     
     
     
     
            foreach ($publishers as $publisher) {
     
     
     
     
            $Resultat .= "<tr><td>" . $publisher['IDEmployePointages'] . "</td><td>" . $publisher['NomCompletEmployes'] . "</td><td>" . $publisher['LibelleDepartement'] . "</td><td>" . $publisher['LibelleService'] . "</td><td>" . $publisher['DatePointages'] . "</td><td> " . $publisher['HeurPointages'] . "</td><td>" . $publisher['salle'] . "</td>
    
    <td style="color:<?= $publisher['statut'] === 'A' ? 'red' : 'inherit' ?>"">
        <?= $publisher['statut'] ?>
    </td><td>" . $publisher['seances'] . "</td></tr>"; 
     
     
     
     
     
     
     
            }
        }
    } else {
        if ($IDEmp == 'T') {
            $SqlRecherche = "SELECT  * FROM Employes,Service,Departement,Affectation,xhistorique WHERE Service.IDService=Affectation.IDService AND Employes.IDEmployes=xhistorique.IDEmployePointages AND Service.IDDepartement=Departement.IDDepartement AND Employes.UIDEmployes=Affectation.IDEmployes AND ActiveEmp!=0 AND Service.IDService=".$IDSer." AND xhistorique.seances=".$TxtIDSea." AND Departement.IDDepartement=".$IDDep."; ";
        } else {
            $SqlRecherche = "SELECT * FROM Employes,Service,Departement,Affectation,xhistorique WHERE Service.IDService=Affectation.IDService AND Employes.IDEmployes=xhistorique.IDEmployePointages AND Service.IDDepartement=Departement.IDDepartement AND Employes.UIDEmployes=Affectation.IDEmployes AND ActiveEmp!=0 AND Service.IDService=".$IDSer." AND Departement.IDDepartement=".$IDDep." AND xhistorique.seances=".$TxtIDSea." AND Employes.IDEmployes=".$IDEmp."";
        }
     
       // echo $SqlRecherche."<br/>";
        echo '<div class="card border-left-success shadow h-50 py-2">
            <div class="card-body">
                <div class="row no-gutters align-items-center">
                    <div class="col mr-2">
                        <div class="text-xs font-weight-bold text-success text-uppercase mb-1">Recherche
                        </div>
                        <div class="row no-gutters align-items-center"> Département : <b>' . $TxtIDDep . '</b> - Filière : <b>' . $TxtIDSer . '</b> - Etudiants : <b>' . $TxtIDEmp . '</b> - Seances : <b>' . $TxtIDSea . '</b></div>
                    </div>
                    <div class="col-auto">
                    <i class="fas fa-search fa-2x text-red-300"></i>
                    </div>
                </div>
            </div>
        </div>';
     
        $Resultat .= "
     
     
     
        <table class='table table-bordered' id='dataTable' width='100%' cellspacing='0'>
    <thead>
        <tr>
            <th>Matricule</th>
            <th>Nom</th>
           <!--th>N° Card</th!-->
            <th>Département</th>
            <th>Filière</th>
            <!--th>Pointage</th!-->
            <th>Date</th>
            <th>Heure</th>
            <!--th>Type</th!-->
            <th>Salle</th>
             <th>Statut</th>
            <th>Seances</th>
        </tr>
    </thead>
    <tbody >";
        $statement = $conn->query($SqlRecherche);
        $publishers = $statement->fetchAll(PDO::FETCH_ASSOC);
     
        if ($publishers) {
     
            foreach ($publishers as $publisher) {
               $Color = "red";
                 $Resultat .= "<tr><td>" . $publisher['IDEmployePointages'] . "</td><td>" . $publisher['NomCompletEmployes'] . "</td><td>" . $publisher['LibelleDepartement'] . "</td><td>" . $publisher['LibelleService'] . "</td><td>" . $publisher['DatePointages'] . "</td><td>" . $publisher['HeurPointages'] . "</td><td>" . $publisher['salle'] . "</td><td>" . $publisher['statut'] . "</td><td>" . $publisher['seances'] . "</td></tr>";
            }
        }
    }
     
    //echo $SqlRecherche.'<br/>';
     
     
     
    $Resultat .= "
     
     
     
     
     
    </tbody>
    </table>";
    echo '<input type="text" id="ResInput" value="' . $Resultat . '" hidden/>';
     
     
     
     
    ?>

  6. #6
    Expert éminent
    Avatar de Séb.
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    5 237
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mars 2005
    Messages : 5 237
    Points : 8 501
    Points
    8 501
    Billets dans le blog
    17
    Par défaut
    1. Je ne retrouve pas le code communiqué plus haut, mais c'est en effet bien possible qu'il soit perdu quelque part dans ton script

    2. En temps normal je ne réponds pas aux messages où aucun effort de présentation n'est effectué

  7. #7
    Futur Membre du Club
    Femme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Mars 2023
    Messages
    10
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 22
    Localisation : France, Corse (Corse)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Mars 2023
    Messages : 10
    Points : 8
    Points
    8
    Par défaut
    j'ai fait exactement ce que vous m'avez dit!!!!

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     $Resultat .= "<tr><td>" . $publisher['IDEmployePointages'] . "</td><td>" . $publisher['NomCompletEmployes'] . "</td><td>" . $publisher['LibelleDepartement'] . "</td><td>" . $publisher['LibelleService'] . "</td><td>" . $publisher['DatePointages'] . "</td><td> " . $publisher['HeurPointages'] . "</td><td>" . $publisher['salle'] . "</td>
    
    <td style="color:<?= $publisher['statut'] === 'A' ? 'red' : 'inherit' ?>"">
        <?= $publisher['statut'] ?>
    
    
    </td><td>" . $publisher['seances'] . "</td></tr>";

  8. #8
    Expert éminent
    Avatar de Séb.
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    5 237
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mars 2005
    Messages : 5 237
    Points : 8 501
    Points
    8 501
    Billets dans le blog
    17
    Par défaut
    Lorsque c'est moche visuellement c'est souvent qu'il y a un problème, et là c'est très moche :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    $Resultat .= "<tr><td>" . $publisher['IDEmployePointages'] . "</td><td>" . $publisher['NomCompletEmployes'] . "</td><td>" . $publisher['LibelleDepartement'] . "</td><td>" . $publisher['LibelleService'] . "</td><td>" . $publisher['DatePointages'] . "</td><td> " . $publisher['HeurPointages'] . "</td><td>" . $publisher['salle'] . "</td>
     
    <td style="color:<?= $publisher['statut'] === 'A' ? 'red' : 'inherit' ?>"">
        <?= $publisher['statut'] ?>
     
    </td><td>" . $publisher['seances'] . "</td></tr>";
    Même la coloration syntaxique du forum montre qu'il y a un problème.

    j'ai fait exactement ce que vous m'avez dit!!!!
    Je n'ai sûrement pas dit d'intégrer ma portion de code à une concaténation !
    Il s'agirait de comprendre un minimum ce qui est proposé et de l'intégrer correctement à l'existant.
    Cela ne peut pas fonctionner par hasard ou par magie.
    Présenter le script correctement pourrait aider. Et je n'invente rien, il s'agit de la base de la programmation. Indenter et présenter correctement son code est la première chose qu'on apprend.

    Lorsqu'on le décortique le truc ci-dessous pour le formater on voit que tu as voulu intégrer du PHP dans du PHP :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    $Resultat .= "<tr><td>" . $publisher['IDEmployePointages'] . "</td><td>" . $publisher['NomCompletEmployes'] . "</td><td>" . $publisher['LibelleDepartement'] . "</td><td>" . $publisher['LibelleService'] . "</td><td>" . $publisher['DatePointages'] . "</td><td> " . $publisher['HeurPointages'] . "</td><td>" . $publisher['salle'] . "</td>
     
    <td style="color:<?= $publisher['statut'] === 'A' ? 'red' : 'inherit' ?>"">
        <?= $publisher['statut'] ?>
     
    </td><td>" . $publisher['seances'] . "</td></tr>";
    Après formatage et correction :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    $color = ($publisher['statut'] === 'A') ? 'red' : 'inherit';
    $Resultat .= <<<BUFFER
        <tr>
            <td>{$publisher['IDEmployePointages']}</td>
            <td>{$publisher['NomCompletEmployes']}</td>
            <td>{$publisher['LibelleDepartement']}</td>
            <td>{$publisher['LibelleService']}</td>
            <td>{$publisher['DatePointages']}</td>
            <td>{$publisher['HeurPointages']}</td>
            <td>{$publisher['salle']}</td>
            <td style="color: {$color}">{$publisher['statut']}</td>
            <td>{$publisher['seances']}</td>
        </tr>
        BUFFER;
    C'est mieux non ? (Même si généralement on évite d'intégrer du HTML à du PHP)

    Syntaxe HereDoc => https://www.php.net/manual/fr/langua...syntax.heredoc
    Lecture de la doc => 10 minutes investies pour des heures de gagnées




    ----

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    echo '<input type="text" id="ResInput" value="' . $Resultat . '" hidden/>';
    Je vais faire comme si je n'avais pas vu cette aberration et ce qu'elle implique.

  9. #9
    Membre à l'essai
    Femme Profil pro
    Administrateur de base de données
    Inscrit en
    Février 2023
    Messages
    18
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 24
    Localisation : France, Val d'Oise (Île de France)

    Informations professionnelles :
    Activité : Administrateur de base de données
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2023
    Messages : 18
    Points : 22
    Points
    22
    Par défaut
    Merci Mr Séb tu nous sauve toujours

  10. #10
    Membre à l'essai
    Femme Profil pro
    Administrateur de base de données
    Inscrit en
    Février 2023
    Messages
    18
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 24
    Localisation : France, Val d'Oise (Île de France)

    Informations professionnelles :
    Activité : Administrateur de base de données
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2023
    Messages : 18
    Points : 22
    Points
    22
    Par défaut
    j'ai eu comme code d'erreur ceci

    Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\xampp\htdocs\ismagip\control\F_ShowPointage.php on line 173

    la ligne en question est

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     $color = ($publisher['statut'] === 'A') ? 'red' : 'inherit';

  11. #11
    Expert éminent
    Avatar de Séb.
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    5 237
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mars 2005
    Messages : 5 237
    Points : 8 501
    Points
    8 501
    Billets dans le blog
    17
    Par défaut
    Citation Envoyé par xena_gueriere2000 Voir le message
    j'ai eu comme code d'erreur ceci

    Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\xampp\htdocs\ismagip\control\F_ShowPointage.php on line 173

    la ligne en question est

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     $color = ($publisher['statut'] === 'A') ? 'red' : 'inherit';
    Cette ligne ne peut pas produire cette erreur.

  12. #12
    Membre à l'essai
    Femme Profil pro
    Administrateur de base de données
    Inscrit en
    Février 2023
    Messages
    18
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 24
    Localisation : France, Val d'Oise (Île de France)

    Informations professionnelles :
    Activité : Administrateur de base de données
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2023
    Messages : 18
    Points : 22
    Points
    22
    Par défaut
    je ne sais d'où vient le problème ça me rend folle moi et Michou en galère

  13. #13
    Expert éminent
    Avatar de Séb.
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    5 237
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mars 2005
    Messages : 5 237
    Points : 8 501
    Points
    8 501
    Billets dans le blog
    17
    Par défaut
    Colle ton script.

  14. #14
    Membre à l'essai
    Femme Profil pro
    Administrateur de base de données
    Inscrit en
    Février 2023
    Messages
    18
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 24
    Localisation : France, Val d'Oise (Île de France)

    Informations professionnelles :
    Activité : Administrateur de base de données
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2023
    Messages : 18
    Points : 22
    Points
    22
    Par défaut
    Bonjour MR Séb le voilà tout entier le code que vous nous avez transmis est répété deux fois à partir de la ligne 101 et 173

    et l'erreur qu'on reçoi et la suivante : Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\xampp\htdocs\ismagip\control\F_ShowPointage.php on line 173

    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
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    <script src="vendor/datatables/jquery.dataTables.min.js"></script>
    <script src="vendor/datatables/dataTables.bootstrap4.min.js"></script>
     
    <link href="vendor/datatables/dataTables.bootstrap4.min.css" rel="stylesheet">
    <!-- Page level custom scripts -->
    <script src="js/demo/datatables-demo.js"></script>
     
    <style>
        .red {color: red;}
    </style>
    <?php
     
    include 'F_Connection.php';
    include('../zklib/ZKLib.php');
     
    //debut de la session
    session_name('ZKTeco');
    session_start();
     
    $conn = OpenCon();
     
    $myIniFile = parse_ini_file("../ini/Config.ini", TRUE);
    $host = $myIniFile["pointeurse"]["adr"];
    $zk = new ZKLib($host, 4370);
    $DateFrom = null;
    $DateTo = null;
     
    //recuperation des valeurs
    $IDDep = $_GET['Dep'] ?? "";
    $IDSer = $_GET['Ser'] ?? "";
    $IDEmp = $_GET['Emp'] ?? "";
    $IDSea = $_GET['Sea'] ?? "";
    $TxtIDDep = $_GET['DepTxt'] ?? "";
    $TxtIDSer = $_GET['SerTxt'] ?? "";
    $TxtIDEmp = $_GET['EmpTxt'] ?? "";
    $TxtIDSea = $_GET["SeaTxt"] ?? "";
    if ($_GET['DateFrom'] ?? "") {
        $DateFrom = new DateTime($_GET['DateFrom'] ?? "");
    }
    if ($_GET['DateTo'] ?? "") {
        $DateTo = new DateTime($_GET['DateTo'] ?? "");
    }
    $DayDiff = $_GET['DayDiff'] ?? "";
     
    $SqlRecherche = null;
    $Resultat = "";
    $diff = null;
     
     
     
    if (!empty($DateFrom) && !empty($DateTo)) {
        if ($IDEmp == 'T') {
            $SqlRecherche = "SELECT DISTINCT * FROM Employes,Service,Departement,Affectation,xhistorique WHERE Service.IDService=Affectation.IDService AND Employes.IDEmployes=xhistorique.IDEmployePointages AND Service.IDDepartement=Departement.IDDepartement AND Employes.UIDEmployes=Affectation.IDEmployes AND ActiveEmp!=0 AND Service.IDService=".$IDSer." AND Departement.IDDepartement=".$IDDep." AND xhistorique.seances=".$TxtIDSea." AND xhistorique.DatePointages BETWEEN '".$DateFrom->format('Y-m-d')."' AND '".$DateTo->format('Y-m-d')."' ";
        } else {
            $SqlRecherche = "SELECT DISTINCT * FROM Employes,Service,Departement,Affectation,xhistorique WHERE Service.IDService=Affectation.IDService AND Employes.IDEmployes=xhistorique.IDEmployePointages AND Service.IDDepartement=Departement.IDDepartement AND Employes.UIDEmployes=Affectation.IDEmployes AND ActiveEmp!=0 AND Service.IDService=".$IDSer." AND Departement.IDDepartement=".$IDDep." AND Employes.IDEmployes=".$IDEmp." AND xhistorique.seances=:".$TxtIDSea." AND xhistorique.DatePointages BETWEEN '".$DateFrom->format('Y-m-d')."' AND '".$DateTo->format('Y-m-d')."'";
        }
     
        //echo $SqlRecherche."<br/>";
        echo '<div class="card border-left-success shadow h-50 py-2">
            <div class="card-body">
                <div class="row no-gutters align-items-center">
                    <div class="col mr-2">
                        <div class="text-xs font-weight-bold text-success text-uppercase mb-1">Recherche
                        </div>
                        <div class="row no-gutters align-items-center"> Département : <b>' . $TxtIDDep . '</b> - Filière : <b>' . $TxtIDSer . '</b> - Employée : <b>' . $TxtIDEmp . '</b> <b> - Seances : <b>' . $TxtIDSea . '</b> |  De : <b>' . $DateFrom->format('Y-m-d') . '</b> - A : <b>' . $DateTo->format('Y-m-d') . '</b> - Totale Jours : ' . $DayDiff . '</div>
                    </div>
                    <div class="col-auto">
                        <i class="fas fa-search fa-2x text-red-300"></i>
                    </div>
                </div>
            </div>
        </div>';
        $Resultat .= "<table class='table table-bordered' id='dataTable' width='100%' cellspacing='0'>
    <thead>
        <tr>
            <th>Matricule</th>
            <th>Nom</th>
            <!--th>N° Card</th!-->
            <th>Département</th>
            <th>Filière</th>
            <!--th>Pointage</th!-->
            <th>Date</th>
            <th>Heure</th>
            <!--th>Type</th!-->
            <th>Salle</th>
            <th>Statut</th>
            <th>Seances</th>
        </tr>
    </thead>
    <tbody >";
     
     
        $statement = $conn->query($SqlRecherche);
        $publishers = $statement->fetchAll(PDO::FETCH_ASSOC);
     
        if ($publishers) {
     
            foreach ($publishers as $publisher) {
     
     
    $color = ($publisher['statut'] === 'A') ? 'red' : 'inherit';
    $Resultat .= <<<BUFFER
        <tr>
            <td>{$publisher['IDEmployePointages']}</td>
            <td>{$publisher['NomCompletEmployes']}</td>
            <td>{$publisher['LibelleDepartement']}</td>
            <td>{$publisher['LibelleService']}</td>
            <td>{$publisher['DatePointages']}</td>
            <td>{$publisher['HeurPointages']}</td>
            <td>{$publisher['salle']}</td>
            <td style="color: {$color}">{$publisher['statut']}</td>
            <td>{$publisher['seances']}</td>
        </tr>
        BUFFER;
     
     
     
     
     
     
            }
        }
    } else {
        if ($IDEmp == 'T') {
            $SqlRecherche = "SELECT  * FROM Employes,Service,Departement,Affectation,xhistorique WHERE Service.IDService=Affectation.IDService AND Employes.IDEmployes=xhistorique.IDEmployePointages AND Service.IDDepartement=Departement.IDDepartement AND Employes.UIDEmployes=Affectation.IDEmployes AND ActiveEmp!=0 AND Service.IDService=".$IDSer." AND xhistorique.seances=".$TxtIDSea." AND Departement.IDDepartement=".$IDDep."; ";
        } else {
            $SqlRecherche = "SELECT * FROM Employes,Service,Departement,Affectation,xhistorique WHERE Service.IDService=Affectation.IDService AND Employes.IDEmployes=xhistorique.IDEmployePointages AND Service.IDDepartement=Departement.IDDepartement AND Employes.UIDEmployes=Affectation.IDEmployes AND ActiveEmp!=0 AND Service.IDService=".$IDSer." AND Departement.IDDepartement=".$IDDep." AND xhistorique.seances=".$TxtIDSea." AND Employes.IDEmployes=".$IDEmp."";
        }
     
       // echo $SqlRecherche."<br/>";
        echo '<div class="card border-left-success shadow h-50 py-2">
            <div class="card-body">
                <div class="row no-gutters align-items-center">
                    <div class="col mr-2">
                        <div class="text-xs font-weight-bold text-success text-uppercase mb-1">Recherche
                        </div>
                        <div class="row no-gutters align-items-center"> Département : <b>' . $TxtIDDep . '</b> - Filière : <b>' . $TxtIDSer . '</b> - Etudiants : <b>' . $TxtIDEmp . '</b> - Seances : <b>' . $TxtIDSea . '</b></div>
                    </div>
                    <div class="col-auto">
                    <i class="fas fa-search fa-2x text-red-300"></i>
                    </div>
                </div>
            </div>
        </div>';
     
        $Resultat .= "
    
    
          
        <table class='table table-bordered' id='dataTable' width='100%' cellspacing='0'>
    <thead>
        <tr>
            <th>Matricule</th>
            <th>Nom</th>
           <!--th>N° Card</th!-->
            <th>Département</th>
            <th>Filière</th>
            <!--th>Pointage</th!-->
            <th>Date</th>
            <th>Heure</th>
            <!--th>Type</th!-->
            <th>Salle</th>
             <th>Statut</th>
            <th>Seances</th>
        </tr>
    </thead>
    <tbody >";
        $statement = $conn->query($SqlRecherche);
        $publishers = $statement->fetchAll(PDO::FETCH_ASSOC);
     
        if ($publishers) {
     
    $color = ($publisher['statut'] === 'A') ? 'red' : 'inherit';
    $Resultat .= <<<BUFFER
        <tr>
            <td>{$publisher['IDEmployePointages']}</td>
            <td>{$publisher['NomCompletEmployes']}</td>
            <td>{$publisher['LibelleDepartement']}</td>
            <td>{$publisher['LibelleService']}</td>
            <td>{$publisher['DatePointages']}</td>
            <td>{$publisher['HeurPointages']}</td>
            <td>{$publisher['salle']}</td>
            <td style="color: {$color}">{$publisher['statut']}</td>
            <td>{$publisher['seances']}</td>
        </tr>
        BUFFER;
     
            }
        }
     
     
    //echo $SqlRecherche.'<br/>';
     
     
     
    $Resultat .= "
    
    
    
    
    
    </tbody>
    </table>";
    echo '<input type="text" id="ResInput" value="' . $Resultat . '" hidden/>';
     
     
     
     
    ?>

  15. #15
    Expert éminent
    Avatar de Séb.
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    5 237
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mars 2005
    Messages : 5 237
    Points : 8 501
    Points
    8 501
    Billets dans le blog
    17
    Par défaut
    $publisher ne vaut rien ligne 173 => Tu oublies le fetch du résultat SQL

  16. #16
    Membre à l'essai
    Femme Profil pro
    Administrateur de base de données
    Inscrit en
    Février 2023
    Messages
    18
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 24
    Localisation : France, Val d'Oise (Île de France)

    Informations professionnelles :
    Activité : Administrateur de base de données
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2023
    Messages : 18
    Points : 22
    Points
    22
    Par défaut
    j'ai rien compris monsieur !!!!!

  17. #17
    Membre du Club
    Femme Profil pro
    Développeur Web
    Inscrit en
    Mars 2023
    Messages
    31
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 30
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Mars 2023
    Messages : 31
    Points : 47
    Points
    47
    Par défaut
    A ta ligne 137 la variable $publisher n'est nullement défini.

    Je pense qu'il manque un foreach avant ?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    if ($publishers) { 
            foreach ($publishers as $publisher) {
    //ICI ton code
    }
    }

  18. #18
    Membre à l'essai
    Femme Profil pro
    Administrateur de base de données
    Inscrit en
    Février 2023
    Messages
    18
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 24
    Localisation : France, Val d'Oise (Île de France)

    Informations professionnelles :
    Activité : Administrateur de base de données
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2023
    Messages : 18
    Points : 22
    Points
    22
    Par défaut
    Bonjour monsieur Seb , non il manque rien avant mon code marche nikel c'est au moment que on a rajouté votre code qu'on reçois le message d'erreur

Discussions similaires

  1. Donner une valeur à un texte
    Par robinet sauvage dans le forum Excel
    Réponses: 12
    Dernier message: 01/02/2022, 19h53
  2. Réponses: 5
    Dernier message: 03/10/2014, 09h10
  3. Réponses: 5
    Dernier message: 14/06/2006, 16h35
  4. donner une valeur par defaut à un champ file
    Par Davboc dans le forum Balisage (X)HTML et validation W3C
    Réponses: 3
    Dernier message: 24/02/2006, 11h26
  5. Réponses: 2
    Dernier message: 07/07/2005, 18h11

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