CheckBox pour sélection des champs de la BD
Bonjour tout le monde.
Je reviens vers vous après de longues heures de recherche.
J'explique le problème:
J'affiche la liste des tâches en cours de validation par le N+1, réalisées par chaque employé.
Je souhaiterais pouvoir sélectionner les tâches que je souhaiterais valider et envoyer une requête de validation pour tous ses champs. ( Genre quand on veut supprimer des messages sur la boite mail soit on sélectionne tous les mails ou bien un par un).
Je souhaiterais faire apparaitre un CheckBox qui, en le cochant, me permettrait de sélectionner tous les champs et avoir des CheckBox pour chaque ligne que je peux cocher ou décocher à part. Un bouton Valider et un autre ne pas valider.
Voici un extrait de mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
<?php
try{
$connect = new PDO("mysql:host=localhost;dbname=test;charset=utf8","root","test");
$connect -> setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e){
echo 'echec de la connexion : ' .$e->getMessage();
}
$requete= $connect->prepare('SELECT * FROM lesTaches WHERE etat1="En cours" OR etat2="En cours" OR etat3="En cours" OR etat4="En cours" ');
$requete->execute();
?> |
Je sélectionne ensuite toutes les tâches réalisées différentes de "RAS"
Code:
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
|
<table id="employee_data" class="table table-striped table-bordered">
<thead>
<tr>
<td style="font-weight: bold;">Nom </td>
<td style="font-weight: bold;">Tâche </td>
<td style="font-weight: bold;">Temps passé</td>
<td style="font-weight: bold;">Date</td>
<td style="font-weight: bold;">Fonction</td>
<td style="font-weight: bold;">Etat</td>
</tr>
</thead>
<?php
while($row = $requete->fetch())
{
?>
<tr>
<td><?php echo $row["nom"]; ?></td>
<td><?php echo $row["tache1"]; ?></td>
<td><?php echo $row["t1"]; ?></td>
<td><?php echo $row["date"]; ?></td>
<td><?php echo $row["fnc"]; ?></td>
<td style="font-weight: bold; color:#00008B"><?php echo $row["etat1"]; ?></td>
</tr>
<?php ;
if ( $row["tache2"] != "RAS" ) {
?>
<tr>
<td><?php echo $row["nom"]; ?></td>
<td><?php echo $row["tache2"]; ?></td>
<td><?php echo $row["t2"]; ?></td>
<td><?php echo $row["date"]; ?></td>
<td><?php echo $row["fnc"]; ?></td>
<td style="font-weight: bold; color:#00008B"><?php echo $row["etat2"]; ?></td>
</tr>
<?php ;
}
if ( $row["tache3"] != "RAS" ) {
?>
<tr>
<td><?php echo $row["nom"]; ?></td>
<td><?php echo $row["tache3"]; ?></td>
<td><?php echo $row["t3"]; ?></td>
<td><?php echo $row["date"]; ?></td>
<td><?php echo $row["fnc"]; ?></td>
<td style="font-weight: bold; color:#00008B"><?php echo $row["etat3"]; ?></td>
</tr>
<?php ;
}
if ( $row["tache4"] != "RAS" ) {
?>
<tr>
<td><?php echo $row["nom"]; ?></td>
<td><?php echo $row["tache4"]; ?></td>
<td><?php echo $row["t4"]; ?></td>
<td><?php echo $row["date"]; ?></td>
<td><?php echo $row["fnc"]; ?></td>
<td style="font-weight: bold; color:#00008B"><?php echo $row["etat4"]; ?></td>
</tr>
<?php ;
}
} |
La structure de ma table "lesTaches" est la suivante : id, nom, tache1,t1,etat1, tache2,t2,etat2, tache3,t3,etat3, tache4,t4,etat4,date,fnc.
d'ou les t1,t2,t3,t4 sont les temps passés sur chaque tache, les états c'est l'état de la tâche qui est sur En cours et en validant ça passe sur "Validé" ou "Pas validé"
J'espère que j'ai été clair et merci d'avance de votre aide.