Si tu n'as plus de liste de classe tu vas mettre à la place une liste d'étudiants où on va choisir un étudiant. On doit donc remplacer dans le code PHP et MySQL tous ce qui était relatif à la classe par une relativité à l'étudiant et notamment à l'idEtudiant.
Voici une correction dans ce sens :
<?php
// init
$date = isset($_GET['date'])? $_GET['date'] : null;
$idEtudiant = isset($_GET['idEtudiant'])? $_GET['idEtudiant'] : null;
//
$nomProf_mat_t1 = isset($_GET['nomProf_mat_t1']) ? $_GET['nomProf_mat_t1'] : null;
$nomProf_mat_t2 = isset($_GET['nomProf_mat_t2']) ? $_GET['nomProf_mat_t2'] : null;
$nomProf_amidi_t1 = isset($_GET['nomProf_amidi_t1']) ? $_GET['nomProf_amidi_t1'] : null;
$nomProf_amidi_t2 = isset($_GET['nomProf_amidi_t2']) ? $_GET['nomProf_amidi_t2'] : null;
//
$nomMatiere_mat_t1 = isset($_GET['nomMatiere_mat_t1']) ? $_GET['nomMatiere_mat_t1'] : null;
$nomMatiere_mat_t2 = isset($_GET['nomMatiere_mat_t2']) ? $_GET['nomMatiere_mat_t2'] : null;
$nomMatiere_amidi_t1 = isset($_GET['nomMatiere_amidi_t1']) ? $_GET['nomMatiere_amidi_t1'] : null;
$nomMatiere_amidi_t2 = isset($_GET['nomMatiere_amidi_t2']) ? $_GET['nomMatiere_amidi_t2'] : null;
// variable pour savoir s'il faut créer une nouvelle absence ou modifier une existante
$mode_ajout = isset($_GET['mode_ajout'])? $_GET['mode_ajout'] : null;
// connexion à la base de données
mysql_select_db("bd_Etudiants", @mysql_connect("localhost","root","")) or die(mysql_error());
mysql_query("SET NAMES UTF8");
// enregistrer la saisie du formulaire
if (isset($_GET['action']) && $_GET['action']=='Enregistrer')
{
//
$message = "";
if (empty($date)) $message .= "<p>La date est obligatoire !</p>";
if (empty($idEtudiant)) $message .= "<p>L'étudiant est obligatoire !</p>";
if (empty($nomMatiere_mat_t1) || empty($nomMatiere_mat_t2)
||empty($nomMatiere_amidi_t1) || empty($nomMatiere_amidi_t2)) $message .= "<p>La matière est obligatoire !</p>";
if (empty($nomProf_mat_t1) || empty($nomProf_mat_t2)
||empty($nomProf_amidi_t1) || empty($nomProf_amidi_t2)) $message .= "<p>Le/la prof est obligatoire !</p>";
//
if (empty($message))
{
$listeAbsences = isset($_GET['absences'])?$_GET['absences']:array();
//echo "<pre>"; print_r($listeAbsences); echo "</pre>";
$sql = "SELECT * FROM Etudiant WHERE idEtudiant = '".$idEtudiant."';";
$result = mysql_query($sql) or die(mysql_error());
while($result && $row=mysql_fetch_array($result))
{
$idEtudiant = $row['idEtudiant']; $nomEtudiant = $row['nom'];
$presence_mat_t1 = isset($listeAbsences["$idEtudiant"]['mat_t1'])?0:1;
$presence_mat_t2 = isset($listeAbsences["$idEtudiant"]['mat_t2'])?0:1;
$presence_amidi_t1 = isset($listeAbsences["$idEtudiant"]['amidi_t1'])?0:1;
$presence_amidi_t2 = isset($listeAbsences["$idEtudiant"]['amidi_t2'])?0:1;
//
// Nouvel enregistrement ou Mise à jour
if ($mode_ajout==true){
$sql="INSERT INTO assiduite SET date='".$date."', idEtudiant='".$idEtudiant."',
presence_mat_t1='".$presence_mat_t1."',
presence_mat_t2='".$presence_mat_t2."',
presence_amidi_t1='".$presence_amidi_t1."',
presence_amidi_t2='".$presence_amidi_t2."',
nomProf_mat_t1 = '".$nomProf_mat_t1."',
nomProf_mat_t2 = '".$nomProf_mat_t2."',
nomProf_amidi_t1 = '".$nomProf_amidi_t1."',
nomProf_amidi_t2 = '".$nomProf_amidi_t2."',
nomMatiere_mat_t1 = '".$nomMatiere_mat_t1."',
nomMatiere_mat_t2 = '".$nomMatiere_mat_t2."',
nomMatiere_amidi_t1 = '".$nomMatiere_amidi_t1."',
nomMatiere_amidi_t2 = '".$nomMatiere_amidi_t2."';";
} else {
$sql="UPDATE assiduite SET
presence_mat_t1='".$presence_mat_t1."',
presence_mat_t2='".$presence_mat_t2."',
presence_amidi_t1='".$presence_amidi_t1."',
presence_amidi_t2='".$presence_amidi_t2."',
nomProf_mat_t1 = '".$nomProf_mat_t1."',
nomProf_mat_t2 = '".$nomProf_mat_t2."',
nomProf_amidi_t1 = '".$nomProf_amidi_t1."',
nomProf_amidi_t2 = '".$nomProf_amidi_t2."',
nomMatiere_mat_t1 = '".$nomMatiere_mat_t1."',
nomMatiere_mat_t2 = '".$nomMatiere_mat_t2."',
nomMatiere_amidi_t1 = '".$nomMatiere_amidi_t1."',
nomMatiere_amidi_t2 = '".$nomMatiere_amidi_t2."'
WHERE date='".$date."' AND idEtudiant='".$idEtudiant."';";
}
//
//echo $sql;
if (!@mysql_query($sql)) $message .= "<li>".$nomEtudiant." => Erreur : ".mysql_error()."</li>";
}
if (empty($message)) $message = "Enregistrement effectué avec succès";
else $message = "<p>Les Erreurs suivantes sont rencontrées :</ul>" . $message . "</ul></p>";
}
}
// crée la liste des Etudiants
$listeEtudiants = "";
$sql = "SELECT * FROM Etudiant ORDER BY idClasse, nom, prenom;";
$result = mysql_query($sql) or die(mysql_error());
while($result && $row=mysql_fetch_array($result))
{
$selected = $row['idEtudiant']==$idEtudiant? " selected " : "";
$listeEtudiants .= "<option value=\"".$row['idEtudiant']."\" ".$selected." >".$row['nom']." ".$row['prenom']." (".$row['idClasse'].")</option>";
}
// crée la listeAssiduiteEtudiants
$listeAssiduiteEtudiants = "";
if (isset($idEtudiant) && !empty($idEtudiant) && isset($date) && !empty($date))
{
// on fait une jointure externe à gauche du côté de la table client vers la table assiduité
// pour afficher tous les élèves de la classe même si les données de présence sont NULL (cas nouvelle saisie)
$sql = "SELECT a.*, total_ha.*, e.*
FROM Etudiant e LEFT OUTER JOIN assiduite a ON e.idEtudiant=a.idEtudiant AND a.date=date('".$date."')
LEFT OUTER JOIN total_heures_absence total_ha ON e.idEtudiant=total_ha.idEtudiant
WHERE e.idEtudiant = '".$idEtudiant."'
ORDER BY e.nom, e.prenom";
//echo $sql;
$result = mysql_query($sql) or die(mysql_error());
while($result && $row=mysql_fetch_array($result))
{
// si les données d'assiduité sont NULL (surtout la date) alors il s'agit d'une nouvelle feuille de présence
// sinon affiche l'absence sous 4 tranches horaires : 2 le matin(mat_t1 et mat_t2) et 2 l'après-midi(amidi_t1 et amidi_t2)
if (is_null($row["date"])) $mode_ajout = true; else $mode_ajout = false;
// stat du total des nbre_heures_absence
$nbre_heures_absence = $row['nbre_heures_absence'];
//
$nomProf_mat_t1 = $row['nomProf_mat_t1'];
$nomProf_mat_t2 = $row['nomProf_mat_t2'];
$nomProf_amidi_t1 = $row['nomProf_amidi_t1'];
$nomProf_amidi_t2 = $row['nomProf_amidi_t2'];
//
$nomMatiere_mat_t1 = $row['nomMatiere_mat_t1'];
$nomMatiere_mat_t2 = $row['nomMatiere_mat_t2'];
$nomMatiere_amidi_t1 = $row['nomMatiere_amidi_t1'];
$nomMatiere_amidi_t2 = $row['nomMatiere_amidi_t2'];
//
$mat_t1_checked = $row['presence_mat_t1']!=1 && !is_null($row['presence_mat_t1']) ? " checked " : "";
$mat_t2_checked = $row['presence_mat_t2']!=1 && !is_null($row['presence_mat_t2']) ? " checked " : "";
$amidi_t1_checked = $row['presence_amidi_t1']!=1 && !is_null($row['presence_amidi_t1']) ? " checked " : "";
$amidi_t2_checked = $row['presence_amidi_t2']!=1 && !is_null($row['presence_amidi_t2']) ? " checked " : "";
//
$listeAssiduiteEtudiants .= "<tr><td>".$row['nom']." ".$row['prenom']."</td>
<td><input type=\"checkbox\" name=\"absences[".$row['idEtudiant']."][mat_t1]\" ".$mat_t1_checked." /> Absent(e)</td>
<td><input type=\"checkbox\" name=\"absences[".$row['idEtudiant']."][mat_t2]\" ".$mat_t2_checked." /> Absent(e)</td>
<td><input type=\"checkbox\" name=\"absences[".$row['idEtudiant']."][amidi_t1]\" ".$amidi_t1_checked." /> Absent(e)</td>
<td><input type=\"checkbox\" name=\"absences[".$row['idEtudiant']."][amidi_t2]\" ".$amidi_t2_checked." /> Absent(e)</td>
<td>" . $nbre_heures_absence . "</td></tr>";
}
}
// crée les listes des matières
$listeMatieres_mat_t1 = "";
$listeMatieres_mat_t2 = "";
$listeMatieres_amidi_t1 = "";
$listeMatieres_amidi_t2 = "";
$sql = "SELECT * FROM matiere ORDER BY nom;";
$result = mysql_query($sql) or die(mysql_error());
while($result && $row=mysql_fetch_array($result))
{
$selected = $row['nom']==$nomMatiere_mat_t1? " selected " : "";
$listeMatieres_mat_t1 .= "<option value=\"".$row['nom']."\" ".$selected." >".$row['nom']."</option>";
//
$selected = $row['nom']==$nomMatiere_mat_t2? " selected " : "";
$listeMatieres_mat_t2 .= "<option value=\"".$row['nom']."\" ".$selected." >".$row['nom']."</option>";
//
$selected = $row['nom']==$nomMatiere_amidi_t1? " selected " : "";
$listeMatieres_amidi_t1 .= "<option value=\"".$row['nom']."\" ".$selected." >".$row['nom']."</option>";
//
$selected = $row['nom']==$nomMatiere_amidi_t2? " selected " : "";
$listeMatieres_amidi_t2 .= "<option value=\"".$row['nom']."\" ".$selected." >".$row['nom']."</option>";
}
// crée les listes des profs
$listeProfs_mat_t1 = "";
$listeProfs_mat_t2 = "";
$listeProfs_amidi_t1 = "";
$listeProfs_amidi_t2 = "";
$sql = "SELECT * FROM prof ORDER BY nom;";
$result = mysql_query($sql) or die(mysql_error());
while($result && $row=mysql_fetch_array($result))
{
$selected = $row['nom']==$nomProf_mat_t1? " selected " : "";
$listeProfs_mat_t1 .= "<option value=\"".$row['nom']."\" ".$selected." >".$row['nom']."</option>";
//
$selected = $row['nom']==$nomProf_mat_t2? " selected " : "";
$listeProfs_mat_t2 .= "<option value=\"".$row['nom']."\" ".$selected." >".$row['nom']."</option>";
//
$selected = $row['nom']==$nomProf_amidi_t1? " selected " : "";
$listeProfs_amidi_t1 .= "<option value=\"".$row['nom']."\" ".$selected." >".$row['nom']."</option>";
//
$selected = $row['nom']==$nomProf_amidi_t2? " selected " : "";
$listeProfs_amidi_t2 .= "<option value=\"".$row['nom']."\" ".$selected." >".$row['nom']."</option>";
}
// fin de connexion
mysql_close();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Gestion d'assiduité des élèves</title>
<link rel="stylesheet" type="text/css" href="calendrier.css">
<script type="text/javascript" src="calendrier.js"></script>
</head>
<body>
<h1>Gestion d'assiduité des élèves</h1>
<form name="form1" action="" method="get">
<table>
<tr>
<th>Etudiant :</th><td><select name="idEtudiant" onchange="form1.submit();" value="<?php echo $idEtudiant; ?>" >
<option value="" ></option>
<?php echo $listeEtudiants; ?>
</select></td>
<th>Date : </th><td><input type="text" id="dateLib" name="date" value="<?php echo $date; ?>" style="width:180px"
onfocus="visuCal(this,{'format' : '%a-%m-%j'})" onblur="masqueCal(this);" />
<input type="submit" name="action" value="Valider la date" />
</td>
</tr>
</table>
<hr />
<?php if ($mode_ajout==true) { ?>
<h2>Nouvelle Feuille de présence du <?php echo date("d-m-Y",strtotime($date)); ?></h2>
<p>Veuillez cocher une case pour désigner une absence.<br />
Pour ajouter cette feuille dans la base de données, appuyer sur le bouton Enregistrer</p>
<?php } else { ?>
<h2>Feuille de présence existante du <?php echo date("d-m-Y",strtotime($date)); ?></h2>
<p>Veuillez cocher une case pour désigner une absence.<br />
Vous pouvez modifie cette feuille puis appuyer sur le bouton Enregistrer pour mettre à jour la base de données.</p>
<?php } ?>
<table border="1">
<tr><th>Nom - Prenom</th><th>8h00 - 10h00</th><th>10h00 - 12h00</th><th>13h30 - 15h30</th><th>15h30 - 17h30</th><th>Total heures d'absences</th></tr>
<?php echo $listeAssiduiteEtudiants; ?>
<tr>
<th>Prof : </th>
<td><select name="nomProf_mat_t1" value="<?php echo $nomProf_mat_t1; ?>" >
<option value="" ></option>
<?php echo $listeProfs_mat_t1; ?>
</select></td>
<td><select name="nomProf_mat_t2" value="<?php echo $nomProf_mat_t2; ?>" >
<option value="" ></option>
<?php echo $listeProfs_mat_t2; ?>
</select></td>
<td><select name="nomProf_amidi_t1" value="<?php echo $nomProf_amidi_t1; ?>" >
<option value="" ></option>
<?php echo $listeProfs_amidi_t1; ?>
</select></td>
<td><select name="nomProf_amidi_t2" value="<?php echo $nomProf_amidi_t2; ?>" >
<option value="" ></option>
<?php echo $listeProfs_amidi_t2; ?>
</select></td>
</tr>
<tr>
<th>Matière : </th>
<td><select name="nomMatiere_mat_t1" value="<?php echo $nomMatiere_mat_t1; ?>" >
<option value="" ></option>
<?php echo $listeMatieres_mat_t1; ?>
</select></td>
<td><select name="nomMatiere_mat_t2" value="<?php echo $nomMatiere_mat_t2; ?>" >
<option value="" ></option>
<?php echo $listeMatieres_mat_t2; ?>
</select></td>
<td><select name="nomMatiere_amidi_t1" value="<?php echo $nomMatiere_amidi_t1; ?>" >
<option value="" ></option>
<?php echo $listeMatieres_amidi_t1; ?>
</select></td>
<td><select name="nomMatiere_amidi_t2" value="<?php echo $nomMatiere_amidi_t2; ?>" >
<option value="" ></option>
<?php echo $listeMatieres_amidi_t2; ?>
</select></td>
</tr>
</table>
<input type="hidden" name="mode_ajout" value="<?php echo $mode_ajout; ?>" />
<input type="submit" name="action" value="Enregistrer" />
<input type="submit" name="action" value="Exporter" />
</form>
<div id="message"><?php echo isset($message)?$message:''; ?></div>
</body>
</html>
<?php
// Exportation de la feuille vers un fichier excel
if (isset($_GET['action']) && $_GET['action']=='Exporter')
{
include("formAssiduite_Export.php");
}
?>
c'est ce que j'avais fait mais comme je veux que l'on choississe l'année d'études avant l'étudiant sa a dû faire conflit :
fonction_formAssiduite2.php
<?php
//FORMASSIDUITE
//CONNEXION
mysql_select_db("bd_etudiants", @mysql_connect("localhost","root","")) or die(mysql_error());
//VARIABLES
$idEtudiant = !empty($_GET['idEtudiant'])? $_GET['idEtudiant'] : null;
$anneeNiveau = isset($_GET['anneeNiveau'])? $_GET['anneeNiveau'] : null;
$nom = !empty($_GET['nom'])? $_GET['nom'] : null;
$date = isset($_GET['date'])? $_GET['date'] : null;
$dateComplete = isset($_GET['dateComplete'])? $_GET['dateComplete'] : null;
$nomMatiere_mat_t1 = isset($_GET['nomMatiere_mat_t1']) ? $_GET['nomMatiere_mat_t1'] : null;
$nomMatiere_mat_t2 = isset($_GET['nomMatiere_mat_t2']) ? $_GET['nomMatiere_mat_t2'] : null;
$nomMatiere_amidi_t1 = isset($_GET['nomMatiere_amidi_t1']) ? $_GET['nomMatiere_amidi_t1'] : null;
$nomMatiere_amidi_t2 = isset($_GET['nomMatiere_amidi_t2']) ? $_GET['nomMatiere_amidi_t2'] : null;
$nomProf_mat_t1 = isset($_GET['nomProf_mat_t1']) ? $_GET['nomProf_mat_t1'] : null;
$nomProf_mat_t2 = isset($_GET['nomProf_mat_t2']) ? $_GET['nomProf_mat_t2'] : null;
$nomProf_amidi_t1 = isset($_GET['nomProf_amidi_t1']) ? $_GET['nomProf_amidi_t1'] : null;
$nomProf_amidi_t2 = isset($_GET['nomProf_amidi_t2']) ? $_GET['nomProf_amidi_t2'] : null;
$prenom = isset($_GET['prenom']) ? $_GET['prenom'] : null;
$idClasse = isset($_GET['idClasse']) ? $_GET['idClasse'] : null;
// variable pour savoir s'il faut créer une nouvelle absence ou modifier une existante
$mode_ajout = isset($_GET['mode_ajout']) && !empty($_GET['mode_ajout'])? $_GET['mode_ajout'] : null;
//-------------------------------------
// TRAITEMENT DES BOUTON D'ACTION
//-------------------------------------
// enregistrer la saisie du formulaire
if (isset($_GET['action']) && $_GET['action']=='Enregistrer')
{
//
$message = "";
if (empty($date)) $message .= "<p>La date est obligatoire !</p>";
//if (empty($idEtudiant)) $message .= "<p>La sélection d'un étudiant est obligatoire !</p>";
//
if (empty($message))
{
$listeAbsences = isset($_GET['absences'])?$_GET['absences']:array();
//echo "<pre>"; print_r($listeAbsences); echo "</pre>";
$sql = "SELECT * FROM etudiant WHERE idEtudiant = '".$idEtudiant."';";
$result = mysql_query($sql) or die(mysql_error());
while($result && $row=mysql_fetch_array($result))
{
$idEtudiant = $row['idEtudiant']; $nomEtudiant = $row['nom'];
$presence_mat_t1 = isset($listeAbsences["$idEtudiant"]['mat_t1'])?0:1;
$presence_mat_t2 = isset($listeAbsences["$idEtudiant"]['mat_t2'])?0:1;
$presence_amidi_t1 = isset($listeAbsences["$idEtudiant"]['amidi_t1'])?0:1;
$presence_amidi_t2 = isset($listeAbsences["$idEtudiant"]['amidi_t2'])?0:1;
//
// Nouvel enregistrement ou Mise à jour
if ($mode_ajout==true){
$sql="INSERT INTO assiduite SET date='".$date."', idEtudiant='".$idEtudiant."',
presence_mat_t1='".$presence_mat_t1."',
presence_mat_t2='".$presence_mat_t2."',
presence_amidi_t1='".$presence_amidi_t1."',
presence_amidi_t2='".$presence_amidi_t2."',
nomProf_mat_t1 = '".$nomProf_mat_t1."',
nomProf_mat_t2 = '".$nomProf_mat_t2."',
nomProf_amidi_t1 = '".$nomProf_amidi_t1."',
nomProf_amidi_t2 = '".$nomProf_amidi_t2."',
nomMatiere_mat_t1 = '".$nomMatiere_mat_t1."',
nomMatiere_mat_t2 = '".$nomMatiere_mat_t2."',
nomMatiere_amidi_t1 = '".$nomMatiere_amidi_t1."',
nomMatiere_amidi_t2 = '".$nomMatiere_amidi_t2."';";
} else {
$sql="UPDATE assiduite SET
presence_mat_t1='".$presence_mat_t1."',
presence_mat_t2='".$presence_mat_t2."',
presence_amidi_t1='".$presence_amidi_t1."',
presence_amidi_t2='".$presence_amidi_t2."',
nomProf_mat_t1 = '".$nomProf_mat_t1."',
nomProf_mat_t2 = '".$nomProf_mat_t2."',
nomProf_amidi_t1 = '".$nomProf_amidi_t1."',
nomProf_amidi_t2 = '".$nomProf_amidi_t2."',
nomMatiere_mat_t1 = '".$nomMatiere_mat_t1."',
nomMatiere_mat_t2 = '".$nomMatiere_mat_t2."',
nomMatiere_amidi_t1 = '".$nomMatiere_amidi_t1."',
nomMatiere_amidi_t2 = '".$nomMatiere_amidi_t2."'
WHERE date='".$date."' AND idEtudiant='".$idEtudiant."';";
}
//
//echo $sql;
if (!@mysql_query($sql)) $message .= "<li>".$nomEtudiant." => Erreur : ".mysql_error()."</li>";
}
if (empty($message)) $message = "Enregistrement effectué avec succès";
else $message = "<p>Les Erreurs suivantes sont rencontrées :</ul>" . $message . "</ul></p>";
}
}
// crée les listes des profs
$listeProfs_mat_t1 = "";
$listeProfs_mat_t2 = "";
$listeProfs_amidi_t1 = "";
$listeProfs_amidi_t2 = "";
$sql = "SELECT * FROM prof ORDER BY nom_prof;";
$result = mysql_query($sql) or die(mysql_error());
while($result && $row=mysql_fetch_array($result))
{
$selected = isset($nomProf_mat_t1)&&$row['nom_prof']==$nomProf_mat_t1? " selected " : "";
$listeProfs_mat_t1 .= "<option value=\"".$row['nom_prof']."\" ".$selected." >".$row['nom_prof']."</option>";
//
$selected = isset($nomProf_mat_t2)&&$row['nom_prof']==$nomProf_mat_t2? " selected " : "";
$listeProfs_mat_t2 .= "<option value=\"".$row['nom_prof']."\" ".$selected." >".$row['nom_prof']."</option>";
//
$selected = isset($nomProf_amidi_t1)&&$row['nom_prof']==$nomProf_amidi_t1? " selected " : "";
$listeProfs_amidi_t1 .= "<option value=\"".$row['nom_prof']."\" ".$selected." >".$row['nom_prof']."</option>";
//
$selected = isset($nomProf_amidi_t2)&&$row['nom_prof']==$nomProf_amidi_t2? " selected " : "";
$listeProfs_amidi_t2 .= "<option value=\"".$row['nom_prof']."\" ".$selected." >".$row['nom_prof']."</option>";
}
//liste des matiere
$listeMatieres_mat_t1 = "";
$listeMatieres_mat_t2 = "";
$listeMatieres_amidi_t1 = "";
$listeMatieres_amidi_t2 = "";
$sql = "SELECT * FROM matiere ORDER BY nom_matiere;";
$result = mysql_query($sql) or die(mysql_error());
while($result && $row=mysql_fetch_array($result))
{
$selected = isset($nomMatiere_mat_t1)&&$row['nom_matiere']==$nomMatiere_mat_t1? " selected " : "";
$listeMatieres_mat_t1 .= "<option value=\"".$row['nom_matiere']."\" ".$selected." >".$row['nom_matiere']."</option>";
//
$selected = isset($nomMatiere_mat_t2)&&$row['nom_matiere']==$nomMatiere_mat_t2? " selected " : "";
$listeMatieres_mat_t2 .= "<option value=\"".$row['nom_matiere']."\" ".$selected." >".$row['nom_matiere']."</option>";
//
$selected = isset($nomMatiere_amidi_t1)&&$row['nom_matiere']==$nomMatiere_amidi_t1? " selected " : "";
$listeMatieres_amidi_t1 .= "<option value=\"".$row['nom_matiere']."\" ".$selected." >".$row['nom_matiere']."</option>";
//
$selected = isset($nomMatiere_amidi_t2)&&$row['nom_matiere']==$nomMatiere_amidi_t2? " selected " : "";
$listeMatieres_amidi_t2 .= "<option value=\"".$row['nom_matiere']."\" ".$selected." >".$row['nom_matiere']."</option>";
}
//LISTES
// remplissage de la liste des étudiants pour l'année sélectionnée
$listeDesEtudiants = "";
$sql = "SELECT * FROM etudiant t1 LEFT JOIN entreprise t2 ON t1.idEntreprise=t2.idEntreprise
WHERE t1.annee='".$anneeNiveau."'";
$result = mysql_query($sql) or die(mysql_error());
while($result && $row=mysql_fetch_array($result))
{
$selected = isset($idEtudiant)&&$row['idEtudiant']==$idEtudiant? " selected " : "";
$listeDesEtudiants .= "<option value=\"".$row['idEtudiant']."\" ".$selected." >".$row['nom']."</option>";
}
// crée la liste des AnneesNiveau
$listeAnneesNiveau = "";
$sql = "SELECT DISTINCT annee FROM Etudiant ORDER BY annee;";
$result = mysql_query($sql) or die(mysql_error());
while($result && $row=mysql_fetch_array($result))
{
$selected = isset($anneeNiveau)&&$row['annee']==$anneeNiveau? " selected " : "";
$listeAnneesNiveau .= "<option value=\"".$row['annee']."\" ".$selected." >".$row['annee']."</option>";
}
// LISTE DES ÉLÈVES DE LA CLASSE SÉLECTIONNÉE
$listeAssiduiteEtudiants = "";
if (isset($date))
{
// on fait une jointure externe à gauche du côté de la table client vers la table assiduité
// pour afficher tous les étudiants de la classe même si les données de présence sont NULL (cas nouvelle saisie)
$sql = "SELECT a.*, total_ha.*, e.*
FROM etudiant e LEFT OUTER JOIN assiduite a ON e.idEtudiant=a.idEtudiant AND a.date=date('".$date."')
LEFT OUTER JOIN total_heures_absence total_ha ON e.idEtudiant=total_ha.idEtudiant
WHERE e.idEtudiant = '".$idEtudiant."'
ORDER BY e.nom, e.prenom";
//echo $sql;
$result = mysql_query($sql) or die(mysql_error());
while($result && $row=mysql_fetch_array($result))
{
// si les données d'assiduité sont NULL (surtout la date) alors il s'agit d'une nouvelle feuille de présence
// sinon affiche l'absence sous 4 tranches horaires : 2 le matin(mat_t1 et mat_t2) et 2 l'après-midi(amidi_t1 et amidi_t2)
if (is_null($row["date"])) $mode_ajout = true; else $mode_ajout = false;
// stat du total des nbre_heures_absence
$nbre_heures_absence = $row['nbre_heures_absence'];
//
$nomProf_mat_t1 = $row['nomProf_mat_t1'];
$nomProf_mat_t2 = $row['nomProf_mat_t2'];
$nomProf_amidi_t1 = $row['nomProf_amidi_t1'];
$nomProf_amidi_t2 = $row['nomProf_amidi_t2'];
//
$nomMatiere_mat_t1 = $row['nomMatiere_mat_t1'];
$nomMatiere_mat_t2 = $row['nomMatiere_mat_t2'];
$nomMatiere_amidi_t1 = $row['nomMatiere_amidi_t1'];
$nomMatiere_amidi_t2 = $row['nomMatiere_amidi_t2'];
//
$mat_t1_checked = $row['presence_mat_t1']!=1 && !is_null($row['presence_mat_t1']) ? " checked " : "";
$mat_t2_checked = $row['presence_mat_t2']!=1 && !is_null($row['presence_mat_t2']) ? " checked " : "";
$amidi_t1_checked = $row['presence_amidi_t1']!=1 && !is_null($row['presence_amidi_t1']) ? " checked " : "";
$amidi_t2_checked = $row['presence_amidi_t2']!=1 && !is_null($row['presence_amidi_t2']) ? " checked " : "";
//
$listeAssiduiteEtudiants .= "<tr><td>".$row['nom']." ".$row['prenom']."</td>
<td><input type=\"checkbox\" name=\"absences[".$row['idEtudiant']."][mat_t1]\" ".$mat_t1_checked." /> Absent(e)</td>
<td><input type=\"checkbox\" name=\"absences[".$row['idEtudiant']."][mat_t2]\" ".$mat_t2_checked." /> Absent(e)</td>
<td><input type=\"checkbox\" name=\"absences[".$row['idEtudiant']."][amidi_t1]\" ".$amidi_t1_checked." /> Absent(e)</td>
<td><input type=\"checkbox\" name=\"absences[".$row['idEtudiant']."][amidi_t2]\" ".$amidi_t2_checked." /> Absent(e)</td>
<td>" . $nbre_heures_absence . "</td></tr>";
}
}
//FIN DE CONNEXION
mysql_close();
?>
et formAssiduite2.php :
<?php
include ("menu.php");
require_once("fonction_formassiduite.php");
?>
<head>
<title>Gestion d'assiduité par Etudiant</title>
</head>
<u><h1>Gestion d'assiduité par Etudiant</h1></u>
<br/><br/>
<b><FONT color="red" size="4"><u>Par Etudiant</u> :</font></b><br/><br/>
<form name="form1" action="" method="get">
<table>
<tr>
<th>
Année d'étude : </th><td>
<select name="anneeNiveau" onChange="form1.submit();">
<option value="" ></option>
<?php echo $listeAnneesNiveau; ?>
</select>
</td>
<th>Etudiant :</th><td> <select name="idEtudiant" >
<option value="" >
</option>
<?php echo isset($listeDesEtudiants)?$listeDesEtudiants:null; ?>
</select></td>
<th> Date : </th><td><input type="text" id="dateLib" name="dateComplete" value="<?php echo isset($dateComplete)?$dateComplete:date("d-m-Y"); ?>" style="width:180px" onfocus="visuCal('date', this,{'format' : '%d, %k %p %a'})" onblur="masqueCal(this);" />
<input type="hidden" id="date" name="date" value="<?php echo isset($date)?date("Y-m-d",strtotime($date)):date("Y-m-d"); ?>" />
<input type="submit" name="action" value="Valider la date" />
</td>
</tr>
</table>
<hr />
<?php if ($mode_ajout==true) { ?>
<h2>Nouvelle Feuille de présence du <?php echo isset($dateComplete)?$dateComplete:date("d-m-Y"); ?></h2>
<p>Veuillez cocher une case pour désigner une absence.<br />
Pour ajouter cette feuille dans la base de données, appuyer sur le bouton Enregistrer</p>
<?php } else { ?>
<h2>Feuille de présence existante du <?php echo isset($date)?date("d-m-Y",strtotime($date)):'Aucune date'; ?></h2>
<p>Veuillez cocher une case pour désigner une absence.<br />
Vous pouvez modifier cette feuille puis appuyer sur le bouton Enregistrer pour mettre à jour la base de données.</p>
<?php } ?>
<table border="1">
<tr>
<th width="82">Nom - Prenom</th>
<th width="66">8h00 - 10h00</th>
<th width="73">10h00 - 12h00</th>
<th width="73">13h30 - 15h30</th>
<th width="73">15h30 - 17h30</th>
<th width="73">Motif</th>
<th width="94">Total heures d'absences</th>
</tr>
<?php echo $listeAssiduiteEtudiants; ?>
<tr>
<th>Prof : </th>
<td><select name="nomProf_mat_t1" value="<?php echo $nomProf_mat_t1; ?>" >
<option value="" ></option>
<?php echo $listeProfs_mat_t1; ?>
</select></td>
<td><select name="nomProf_mat_t2" value="<?php echo $nomProf_mat_t2; ?>" >
<option value="" ></option>
<?php echo $listeProfs_mat_t2; ?>
</select></td>
<td><select name="nomProf_amidi_t1" value="<?php echo $nomProf_amidi_t1; ?>" >
<option value="" ></option>
<?php echo $listeProfs_amidi_t1; ?>
</select></td>
<td><select name="nomProf_amidi_t2" value="<?php echo $nomProf_amidi_t2; ?>" >
<option value="" ></option>
<?php echo $listeProfs_amidi_t2; ?>
</select></td>
</tr>
<tr>
<th>Matière : </th>
<td><select name="nomMatiere_mat_t1" value="<?php echo $nomMatiere_mat_t1; ?>" >
<option value="" ></option>
<?php echo $listeMatieres_mat_t1; ?>
</select></td>
<td><select name="nomMatiere_mat_t2" value="<?php echo $nomMatiere_mat_t2; ?>" >
<option value="" ></option>
<?php echo $listeMatieres_mat_t2; ?>
</select></td>
<td><select name="nomMatiere_amidi_t1" value="<?php echo $nomMatiere_amidi_t1; ?>" >
<option value="" ></option>
<?php echo $listeMatieres_amidi_t1; ?>
</select></td>
<td><select name="nomMatiere_amidi_t2" value="<?php echo $nomMatiere_amidi_t2; ?>" >
<option value="" ></option>
<?php echo $listeMatieres_amidi_t2; ?>
</select></td>
</tr>
</table>
<input type="hidden" name="mode_ajout" value="<?php echo $mode_ajout; ?>" />
<input type="submit" name="action" value="Enregistrer" />
<span class="marge"></span>
<input type="submit" name="action" value="Exporter" />
<input type="button" value="Imprimer" onClick="imprime_zone('feuille_absence');">
</form>
<div id="message"><?php echo isset($message)?$message:''; ?></div>
</div>
<?php
// Exportation de la feuille vers un fichier excel
if (isset($_GET['action']) && $_GET['action']=='Exporter')
{
include("formAssiduite_Export.php");
}
?>
</div>
</body>
</html>
j'ai pourtant changé l'idClasse en idEtudiant mais cela ne fonctionne pas : l'étudiant ne s'affiche pas mais aucun message d'erreur.