<?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>Liste Elèves </title>
<link rel="stylesheet" href="w3.css">
<style type="text/css">
<!--
.style1 {
	font-size: 18px;
	font-weight: bold;
}
body,td,th {
	color: #000033;
}
body {
	background-color: #FFF;
}

@media print  { .noprint  { display: none; }
.page-break  { display:block; page-break-after:always; }
@page  
{ 
   size: 210mm 297mm; 
  /* Chrome sets own margins, we change these printer settings */
  margin: 2mm 2mm 2mm 2mm;
        }

}
	

-->
</style>

<body>
<form method="post" action="listeeleve.php" class="w3-container">
<fieldset>

<?php

include 'header.php';
echo '<div class="noprint">
<table with="90%"  align="left"><tr><td>';
echo "Classe :";
include '_serveur.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'<select name="cont" 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.'">'.$classe.'</option>';
        };
?>
</select>
</td>
<td colspan="2"><label>Date: <input class="w3-input w3-border w3-light-grey"type="date" name="date1" value="<?php echo date('Y-m-d'); ?>" /></label>
<label><button type="button" class="noprint" onclick="window.print()" /><img src="imprimante.png" height="32" width="40" /></label>

</td>
<tr><td colspan="2">
 <input class="w3-btn w3-blue w3-round-medium" type="reset" value="Effacer" /> 
&nbsp;&nbsp;<input class="w3-btn w3-blue w3-round-medium" type="submit" name="envoyer" value="Envoyer" /> ←
&nbsp;&nbsp;<input class="w3-btn w3-blue w3-round-medium" type="submit" name="quitter" value="Quitter" /> ←
<p>&nbsp;</p>
</td></tr>
</table></div>
</fieldset>

</form>

<?php
if (isset ($_POST['envoyer'])){
	$cont1=$_POST['cont'];
$cellm=explode(";",$cont1);
 $classeid=$cellm[0];
 $classe1=$cellm[1];

//On récupère les valeurs entrées par l'utilisateur :
$date1 = $_POST['date1'];

echo $classe1.'&ensp;'.$date1.'</div>
</div>';
$sql = 'SELECT * FROM students  JOIN users on  users.id= students.userID where classID="'.$classeid.'" Order by students.firstName, students.lastName,users.firstName ASC';

   if(!(mysqli_query($link, $sql))){
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
$req=  mysqli_query($link, $sql);
$i=1; $num=1;
echo "<table width='95%' border=1 bordercolor='#666666' cellspacing='0'>"; 
while ($data = mysqli_fetch_array($req)) {
   
       echo "<tr>";
         echo '<td width="30%">'.$num.' '.strtoupper($data['2']).' '.strtoupper($data['8']).' '.strtoupper($data['3']).'</td><td>&nbsp;&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
		 <td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td></tr>';
		
     $i=$i+1;
	 $num++;    
	  
	    }


}
 
   

echo '</div>';
?>
</body>
</html>
