- <?php
- session_start();
- if($_POST['studnr']);
- // Make a MySQL Connection
- include("verbinden.php");
- echo "<table border='1'>
- <tr>
- <th>ID</th>
- <th>Studentnummer</th>
- <th>Voornaam</th>
- </tr>";
- $result = mysql_query("SELECT * FROM student");
- $var = mysql_fetch_array($result);
- {
- echo "<tr>";
- echo "<td>" . $var['id'] . "</td>";
- echo "<td>" . $var['studnr'] . "</td>";
- echo "<td>" . $var['voornaam'] . "</td>";
- echo "</tr>";
- }
- echo "</table>";
- echo '<h1>Cijferoverzicht</h1>';
- ?>
- <a href="javascript:print()"><img src="rapportage24.png" border="0"></a>
- <?php
- echo "<table border='1'>
- <tr>
- <th>Vak</th>
- <th>Cijfers</th>
- <th>Gemiddelde</th>
- </tr>";
- $query = mysql_query("SELECT * FROM resultaten WHERE studnr = '". mysql_real_escape_string($_SESSION['id'] ) ."' ORDER BY vak") or die(mysql_error());
- $i=0;
- $j=0;
- while($var = mysql_fetch_assoc($query)){
- $j++;
- $cijfer_info_vak[$j] = '<strong>Cijfer: '.GetalNetjes($var['resultaat']).'</strong><br>';
- $cijfer_info_vak[$j] .= 'Datum: '.DatumNL($var['datum']).'<br>';
- $cijfer_info_vak[$j] .= 'Niveau: '.$var['niveau'].'<br>';
- $cijfer_info_vak[$j] .= 'Weging: '.$var['weging'].'<br>';
- $cijfer_info_vak[$j] .= 'Opmerking: '.$var['opmerking'].'<br>';
- if ($rij[$i]['vak'] == $var['vak']){
- $rij[$i]['cijfers'] = $rij[$i]['cijfers'] . ' / ' . InfoItje($cijfer_info_vak[$j],intval($var['resultaat']));
- $rij[$i]['wegingopgeteld'] = $rij[$i]['wegingopgeteld'] + $var['weging'];
- $rij[$i]['cijfersopgeteld'] = $rij[$i]['cijfersopgeteld'] + ($var['resultaat'] * $var['weging']);
- $rij[$i]['gemiddelde'] = ($rij[$i]['cijfersopgeteld']/$rij[$i]['wegingopgeteld']);
- }else{
- $i++;
- $rij[$i]['vak'] = $var['vak'];
- $rij[$i]['cijfers'] = InfoItje($cijfer_info_vak[$j],intval($var['resultaat']));
- $rij[$i]['wegingopgeteld'] = $rij[$i]['wegingopgeteld'] + $var['weging'];
- $rij[$i]['cijfersopgeteld'] = $rij[$i]['cijfersopgeteld'] + ($var['resultaat'] * $var['weging']);
- $rij[$i]['gemiddelde'] = ($rij[$i]['cijfersopgeteld']/$rij[$i]['wegingopgeteld']);
- }
- }
- //per regel html maken
- foreach ($rij as $itje){
- echo "<tr>";
- echo "<td>" . $itje['vak'] . "</td>";
- echo "<td>" . $itje['cijfers'] . "</td>";
- echo "<td align=\"right\">" . GetalNetjes($itje['gemiddelde']) . "</td>";
- echo "</tr>";
- }
- echo "</table>";
- //functie om netjes een komma te gebruiken in de weergave van het getal
- function GetalNetjes($getal){
- $val = floatval( $getal );
- $txt = number_format($val,1, ',', '.');
- return $txt;
- }
- //popup met cijfer informatie
- function InfoItje($tekst,$cijfer){
- $info = "<a href=\"javascript:OverviewHisMarks\" onMouseover=\"ddrivetip('";
- $info .= $tekst;
- $info .= "','', 300)\"; onMouseout=\"hideddrivetip()\">".$cijfer."</a>";
- return $info;
- }
- //netjes maken van de datum
- function DatumNL($datum){
- $format = "%d-%m-%Y";
- return (!empty($datum) ? strftime($format, strtotime($datum)) : "" );
- }
- $query = "SELECT studnr, AVG(resultaat) FROM resultaten GROUP BY studnr";
- $result = mysql_query($query) or die(mysql_error());
- // Print out result
- $var = mysql_fetch_array($result);
- echo "Het gemiddelde cijfer van ". $var['studnr']. " is ".$var['AVG(resultaat)'];
- echo "<br />";
- ?>
