<?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">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<title>Mes  Fiches</title>
</head>
<body>
<form method="post"  action="_affichefiched.php">
<?php
include "header.php";
include '_serveur.php';
echo '<table class="w3-table-all" width="90%" border="0" cellpadding="1" cellspacing="1" class="box">';
$sql = 'SELECT * FROM classes order by id';
if(!(mysqli_query($link, $sql))){
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
$req=  mysqli_query($link, $sql);
echo '<p>Matières:';

while ($data = mysqli_fetch_array($req)) {

$classID=$data[0];
$classen=$data[1];
echo ' <input class="w3-check" type="radio" name="cla"  value="'.$classID.";".$classen.'">';
echo $classen."&ensp;";
 
	
}


$sql = 'SELECT * FROM subjects order by id';
if(!(mysqli_query($link, $sql))){
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
$req=  mysqli_query($link, $sql);
echo '<p>Matières:';

while ($data = mysqli_fetch_array($req)) {

$subject=$data[1];
$subjectID=$data[0];
echo ' <input class="w3-check" type="radio" name="cont"  value="'.$subjectID.";".$subject.'">';
echo $subject."&ensp;";
 
	
}


?>

</tr>

<tr> 

&nbsp;&nbsp;&nbsp;&nbsp;
<td ><input name="chercher" type="submit" class="style6" value=" Publier "></td>
</tr>
</table>
</form>

<?php
$date="";
$cycle="";
$circulaire="";


if(isset($_POST['chercher']))
{
	echo '<div class="w3-panel w3-blue w3-round-xlarge">';
echo "<p align='center'>Fiches</p></div>";

$cont1=$_POST['cont'];
$cla1=$_POST['cla'];
	 $cellc=explode(";",$cla1);
 	$classeid=$cellc[0];
    $classe=$cellc[1];
    $cellm=explode(";",$cont1);
    $subjectID=$cellm[0];
     $subject=$cellm[1];
	 
$sql = 'select * from fiches  where classID="'.$classeid.'" and subjectID="'.$subjectID.'" ';
   if(!(mysqli_query($link, $sql))){
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
$req=mysqli_query($link, $sql);
echo '<div class="w3-responsive">';
echo "<table class='w3-table-all'>";

while ($data = mysqli_fetch_array($req)) {
         $url=$data['url'];
		 $classe1=$data['classe'];
		 $title=$data['title'];
		 $date1=$data['date'];
		 echo "<tr ><td width=25% >Classe:". $classe."</td>";
				   echo "<td width=15% >Date:".$date1."</td>";
        echo "<td align='center'><a href=\"./$url\">$title</a><br /></td></tr>";

                    }
echo '</div>';

       

}
?>

</body>
</html>