<!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">
<head>

<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="w3.css">
<title>Eleve Passe</title>
 
</head>
<style>
body {width:90%;}
</style>
<body>

<div class="w3-card-4">
<form method="post" action="_modinscitpass.php" >
<?php
include 'header.php';
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 '<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.'">'.$classe.'</option>';

        };

echo '</select>';

                    
 echo'  <input name="chercher" type="submit" class="style19" value="Envoyer" bgcolor="#CC99FF" /></form></div>';
               
if (isset ($_POST['chercher'])){
	$clas=$_POST['cla'];

	$cellclas=explode(";",$clas);
$classeid=$cellclas[0];
$classe=$cellclas[1];


$sql = 'SELECT * FROM students  left join users on students.userID=users.id
                                left JOIN devices on users.id=devices.userID 
                              where students.classID= "'.$classeid.'"  ';

   if(!(mysqli_query($link, $sql))){
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
echo '<div class="w3-container">';
$j=1;
$req=mysqli_query($link, $sql);
echo "Classe: ".$classe." &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".date('d/m/Y');
while ($data = mysqli_fetch_array($req)) {
// on affiche les résultats
$userid=$data[1];
$firstName=$data[2];
$lastName=$data[3];
$classID=$data[4];
$username=$data[7];
$pass=$data[10];
echo '<div class="w3-container w3-left-align">';
if($j==1) {echo '<table width="90%" border=1 cellspacing=0><tr><td colspan="5"><p align="left"><b>&nbsp;&nbsp;'.$classe.'&nbsp;&nbsp;</b></p></td</tr>';
echo "<tr bgcolor='#BDDCFD'><td>N.</b>&ensp;&ensp;&ensp;&ensp;&ensp;</td><td>Prénom</td>
<td >Nom</td><td >Nom Utilisateur</td><td >Passe</td></tr>";

}
echo "<tr><td>".$userid."</b>&ensp;&ensp;&ensp;&ensp;&ensp;</td><td>".$firstName."</td>
<td >".$lastName."</td><td >".$username."</td><td >".$pass."</td><td><a href='_modpass.php?id=$userid&username=$username&pass=$pass'><img src='edit.jpg' height='50' width='50'></a></td></tr>";

$j=$j+1;

}
}
?>


</body>
</html>