<?php session_start(); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Ecrire les notes </title>

<style type="text/css">
<!--
.style1 {
	font-size: 18px;
	font-weight: bold;
}
body,td,th {
	color: #000033;
}
body {
	background-color: #FFF;
}
-->
</style>

<body>

<div>
<form method="post" action="_listeabsenceclassedate.php">
<?php
include 'header.php';

//$cycle=$_GET['cycle'];
include '_serveur.php';?>
<input name="cycle" type="hidden" value="<?php $cycle=$_REQUEST['cycle']; echo $cycle; ?>">
<?php
$sql = 'SELECT * from classes  order by id ASC';
   if(!(mysqli_query($link, $sql))){
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
$req=  mysqli_query($link, $sql);
echo '<label class="w3-text-teal" >Classe:</label><select name="cla" class="w3-select w3-border w3-light-grey">';

 while($data = mysqli_fetch_array($req)) {
$classe=$data['name'];
$classeid=$data['id'];
$classe=strtoupper($classe);
 echo' <option value="'.$classeid.'">'.$classe.'</option>';
        };

echo '</select>';
echo '</select><label class="w3-text-teal">Date:</label> <input class="w3-input w3-border w3-light-grey" type="date" name="date" value="'.date("Y-m-d").'" />';


echo '<button class="w3-btn w3-blue" name="envoyer">Afficher</button></p>';				   
if (isset ($_POST['envoyer'])){
	$classeid=$_POST['cla'];
	$date=$_POST['date'];
$sql = 'SELECT * from absences join students on absences.studentID=students.id and absences.classID=students.classID
                              join classes on classes.id=absences.classID where absences.classID = "'.$classeid.'" and  absences.date ="'.$date.'"
 order by students.firstName,students.lastName'; 
   if(!(mysqli_query($link, $sql))){
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
    }
echo '<table class="w3-table w3-striped w3-bordered" align="center">';
	 echo "<tr><th><strong>Prénom&emsp;&emsp;Famille</strong> </th>
	 <th>Date</th><th>Absent</th></tr>";

$req=  mysqli_query($link, $sql);
 while($data = mysqli_fetch_array($req)) {
          $date=$data[3];
		  $firstName=$data[7];
		  $lastName=$data[8];
		 echo "<tr><td><strong>".$firstName."&emsp;&emsp;".$lastName."</strong> </td><td><strong>".$date."</td><td><strong>&#9989;</td></tr>";
	  

 }
	
//On récupère les valeurs entrées par l'utilisateur :
}



?>
</body>
</html>
