-
Notifications
You must be signed in to change notification settings - Fork 0
/
ocjene.php
125 lines (110 loc) · 3.51 KB
/
ocjene.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
include_once 'header.php';
if (!($logAdmin || $logRazrednik || $logStaratelj)) {
destroySession();
header("Location: http://localhost/WebImenik/index.php");
die();
}
if ($logStaratelj){
$ucenikID = $logStaratelj;
} elseif ($_SERVER['REQUEST_METHOD'] == 'GET' && isset ($_GET['ucenikID'])) {
$ucenikID = $_GET['ucenikID'];
} else {
destroySession();
header("Location: http://localhost/WebImenik/index.php");
die();
}
$ocjene = queryMysql("SELECT ocjene.predmetID, predmeti.naziv, ocjene.rubrikaBr, ocjene.mjesec, ocjene.ocjena "
. "FROM ocjene LEFT JOIN predmeti ON ocjene.predmetID = predmeti.predmetID "
. "WHERE ocjene.ucenikID = $ucenikID");
$poljeOcjena = array();
$broj = $ocjene->num_rows;
for ($j = 0; $j < $broj; ++$j) {
$ocjena = $ocjene->fetch_array(MYSQLI_ASSOC);
$poljeOcjena[$ocjena['predmetID']][$ocjena['rubrikaBr']][$ocjena['mjesec']] = $ocjena['ocjena'];
}
$razred = queryMysql("SELECT razredID, ime, prezime FROM ucenici WHERE ucenikID = $ucenikID")->fetch_array(MYSQLI_ASSOC);
$razredID = $razred['razredID'];
$imeUcenika = $razred['ime'];
$prezimeUcenika = $razred['prezime'];
if (file_exists("images/$ucenikID.jpg")) $slikaPath = "images/$ucenikID.jpg";
else $slikaPath = "images/dummy.jpg";
?>
<div style="float: right; width: 25%">
<h2><?php echo "$imeUcenika $prezimeUcenika"; ?></h2>
<img src="<?php echo $slikaPath ?>">
</div>
<table class="ocjene">
<tr>
<th>
</th>
<th>
</th>
<th>
IX
</th>
<th>
X
</th>
<th>
XI
</th>
<th>
XII
</th>
<th>
I
</th>
<th>
II
</th>
<th>
III
</th>
<th>
IV
</th>
<th>
V
</th>
<th>
VI
</th>
</tr>
<?php
$predmeti = queryMysql("SELECT predmeti.predmetID, predmeti.naziv, razredi_predmeti.rubrika0, razredi_predmeti.rubrika1, razredi_predmeti.rubrika2, razredi_predmeti.rubrika3, razredi_predmeti.rubrika4 "
. "FROM predmeti INNER JOIN razredi_predmeti ON predmeti.predmetID = razredi_predmeti.predmetID "
. "WHERE razredi_predmeti.razredID = $razredID "
. "ORDER BY predmeti.naziv");
$broj = $predmeti->num_rows;
for ($j = 0; $j < $broj; ++$j){
$predmet = $predmeti->fetch_array(MYSQLI_ASSOC);
echo "<tr><td colspan='12' class='predmet'>" . $predmet['naziv'] . "</td></tr>\r\n";
echo "<tr><td rowspan='5' class='komentar'>Komentari profesora</td>";
for ($i = 0; $i < 5; ++$i) {
if ($predmet['rubrika' . $i] == "") $predmet['rubrika' . $i] = " ";
echo "<td class='rubrika'>" . $predmet['rubrika' . $i] . "</td>\r\n";
for ($k = 0; $k < 10; ++$k) {
echo "<td class='ocjena'>";
if (isset($poljeOcjena[$predmet['predmetID']][$i][$k])) {
echo $poljeOcjena[$predmet['predmetID']][$i][$k];
} else {
echo " ";
}
echo "</td>\r\n";
}
if ($i < 4) echo "</tr><tr>";
}
echo "</tr>";
}
?>
</table>
</body>
</html>