<?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>
<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;
}
-->
</style>

<body>

<div>
<form method="post" action="_ecrirenoteparmatiere4.php" name="john">
<?php
include 'header.php';
$classeid=$subjectId=0;
$coef=$ordre=0;
$classeErr=$subSubjectErr=$coefErr=$ordreErr="";
include '_serveur.php';

$sql = 'SELECT * from classes inner JOIN classesSemesters on classes.id=classesSemesters.classID
                               inner JOIN semesters on semesters.id=classesSemesters.semesterID 
							   where  classesSemesters.teachersActive=1 and classes.cycleID=4 order by classes.id,semesters.id';
							   
   if(!(mysqli_query($link, $sql))){
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
   }
$req=  mysqli_query($link, $sql);
echo '<p>Contrôle:<select name="cont" class="w3-select w3-border w3-light-grey">';

 while($data = mysqli_fetch_array($req)) {
$classID=$data[0];
 $classen=$data[1];
$ctrl=$data[8];
$ctrlID=$data[7];
  echo' <option value="'.$classID.";".$ctrlID.'">'.$classen."   ".$ctrl.'</option>';

 }
echo "</select>";


$sql1 = 'SELECT * from subSubjects JOIN subjects on subjects.id=subSubjects.subjectID
                                    join gradesSubjects on subSubjects.id=gradesSubjects.subSubjectID
									join classes on gradesSubjects.classID=classes.id where classes.id="'.$classID.'" order by subjects.id, subSubjects.id ';
   if(!(mysqli_query($link, $sql1))){
    echo "ERROR: Could not able to execute $sql1. " . mysqli_error($link); 
	}
$req1=  mysqli_query($link, $sql1);
echo 'Matière:<select name="sub" class="w3-select w3-border w3-light-grey">';

 while($data1 = mysqli_fetch_array($req1)) {
$subject=$data1[4]; 
$matiere=$data1[2];
$subSubjectID=$data1[0];
 echo '<option value="'.$subSubjectID.'">'.$subject."-".$matiere.'</option>';
        };

echo '</select>'; 
  echo '<input class="w3-input" type="submit"  name="envoyer" value="Entrer" style="font-size:9px"/>';   
if (isset ($_POST['envoyer'])){

//On récupère les valeurs entrées par l'utilisateur :
$cont1=$_POST['cont'];
$cellm=explode(";",$cont1);
 $classe1=$cellm[0];
 $ctrl1=$cellm[1];
$subSubjectID=$_POST['sub'];
$_SESSION['classe1']=$classe1;
$_SESSION['ctrl1']=$ctrl1;
$_SESSION['subSubjectID']=$subSubjectID;
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=continuernotes.php">';
}
 
?>
</body>
</html>
