Sie sind auf Seite 1von 14

25/01/2019 index2.

php

1 Vjezbe (3)
2 <!DOCTYPE html>
3 <html>
4 <head>
5 <meta charset="utf-8" />
6 <meta http-equiv="X-UA-Compatible" content="IE=edge">
7 <title>Spisak studenata</title>
8 </head>
9 <body>
10 <?php
11 //ovo je komentar
12 $konekcija = mysqli_connect(
13 'localhost',
14 'root',
15 '',
16 'malastudentskabaza'
17 );
18 if(isset($_GET['id'])){
19 $upit = mysqli_query(
20 $konekcija,
21 "DELETE from dosije where indeks=".$_GET['id']
22 );
23 if (!$upit)
24 print "Nije moguce obrisati ovog studenta, jer je polagao neke ispite.<br>";
25 }
26
27 if(isset($_GET['indeks']) && isset($_GET['ime'])){
28 $upit = mysqli_query(
29 $konekcija,
30 "INSERT INTO dosije VALUES (".$_GET['indeks'].",'".$_GET['ime']."',
'".$_GET['prezime']."', ".$_GET['god_r'].", '".$_GET['mjesto_r']."')"
31 );
32 }
33
34 $upit = mysqli_query(
35 $konekcija,
36 "Select * from dosije"
37 );
38 ?>
39 <h1>Studenti</h1>
40 <a href="dodaj_novog_studenta.php">Dodajte novog studenta</a>
41 <table border="1px">
42 <tr>
43 <?php
44 for ($i=0; $i < mysqli_num_fields($upit); $i++) {
45 print '<th>'.mysqli_fetch_field_direct($upit, $i)->name.'</th>';
46 }
47 ?>
48 <th>Brisanje</th>
49 <th>Izmjene</th>
50 </tr>
51 <?php
52 while ($vrsta = mysqli_fetch_array($upit)) {
53 print '<tr>';
54 print '<td><a href="polozeni.php?podatak='.$vrsta[0].'">'.$vrsta[0].'</a>
</td>';
55 for ($i=1; $i < mysqli_num_fields($upit); $i++){
56 print '<td>'.$vrsta[$i].'</td>';
57 }
58 print '<td><a href="index.php?id='.$vrsta[0].'">Obrisite</a></td>';
http://localhost:4649/?mode=php 1/2
25/01/2019 index2.php

59 print '<td><a href="izmjena.php?id='.$vrsta[0].'">Izmijenite</a></td>';


60 print '</tr>';
61 }
62 ?>
63 </table>
64 </body>
65 </html>
66 Dodaj studenta....
67 <!DOCTYPE html>
68 <html>
69 <head>
70 <meta charset="utf-8" />
71 <meta http-equiv="X-UA-Compatible" content="IE=edge">
72 <title>Dodajte novog studenta</title>
73 </head>
74 <body>
75 <form action="index.php" method="get">
76 Indeks <input type="number" name="indeks"><br>
77 Ime <input type="text" name="ime"><br>
78 Prezime <input type="text" name="prezime"><br>
79 Godina rodjenja <input type="number" name="god_r"><br>
80 Mjesto rodjenja <input type="text" name="mjesto_r"><br>
81 <input type="submit" value="Dodaj">
82 </form>
83 </body>
84 </html>

http://localhost:4649/?mode=php 2/2
25/01/2019 polozeni.php

1 Polozeni...
2 <!DOCTYPE html>
3 <html>
4 <head>
5 <meta charset="utf-8" />
6 <meta http-equiv="X-UA-Compatible" content="IE=edge">
7 <title>Polozeni</title>
8 </head>
9 <body>
10 <?php
11 //ovo je komentar
12 $konekcija = mysqli_connect(
13 'localhost',
14 'root',
15 '',
16 'malastudentskabaza'
17 );
18 $upit = mysqli_query(
19 $konekcija,
20 "SELECT naziv, ocena from ispit join predmet on id=id_predmet where ocena>5 and
indeks=".$_GET['podatak']
21 );
22 ?>
23 <h1>Polozeni predmeti</h1>
24 <table border="1px">
25 <tr>
26 <?php
27 for ($i=0; $i < mysqli_num_fields($upit); $i++) {
28 print '<th>'.mysqli_fetch_field_direct($upit, $i)->name.'</th>';
29 }
30 ?>
31 </tr>
32 <?php
33 while ($vrsta = mysqli_fetch_array($upit)) {
34 print '<tr>';
35
36 for ($i=0; $i < mysqli_num_fields($upit); $i++){
37 print '<td>'.$vrsta[$i].'</td>';
38 }
39 print '</tr>';
40 }
41 ?>
42 </table>
43 </body>
44 </html>
45 Izmjena..
46 <!DOCTYPE html>
47 <html>
48 <head>
49 <meta charset="utf-8" />
50 <meta http-equiv="X-UA-Compatible" content="IE=edge">
51 <title>Izmjenite podatke</title>
52 </head>
53 <body>
54 <?php
55 $konekcija = mysqli_connect(
56 'localhost',
57 'root',
58 '',
59 'malastudentskabaza'
http://localhost:4649/?mode=php 1/2
25/01/2019 polozeni.php

60 );
61 if(isset($_POST['ime']))
62 mysqli_query($konekcija,
63 'UPDATE dosije SET ime="'.$_POST['ime'].'", prezime="'.$_POST['prezime'].'",
god_rodjenja='.$_POST['god_r'].', mesto_rodjenja="'.$_POST['mjesto_r'].'" Where
indeks='.$_GET['id']);
64
65 $upit = mysqli_query($konekcija,
66 'SELECT * from dosije WHERE indeks='.$_GET['id']);
67 if($vrsta = mysqli_fetch_array($upit)){
68 ?>
69 <a href="index.php">Nazad</a>
70 <form action="" method="post">
71 Indeks <input type="number" name="indeks" value="<?php print $vrsta[0]; ?>"
disabled><br>
72 Ime <input type="text" name="ime" value="<?php print $vrsta[1]; ?>"><br>
73 Prezime <input type="text" name="prezime" value="<?php print $vrsta[2]; ?>"><br>
74 Godina rodjenja <input type="number" name="god_r" value="<?php print $vrsta[3]; ?
>"><br>
75 Mjesto rodjenja <input type="text" name="mjesto_r" value="<?php print $vrsta[4];
?>"><br>
76 <input type="submit" value="Spremite">
77 </form>
78 <?php } ?>
79 </body>
80 </html>

http://localhost:4649/?mode=php 2/2
25/01/2019 zad1.php

1 Sa casa 1...
2 <!DOCTYPE html>
3 <html>
4 <head>
5 <meta charset="utf-8" />
6 <meta http-equiv="X-UA-Compatible" content="IE=edge">
7 <title>Predmeti</title>
8 </head>
9 <body>
10 <?php
11 $konekcija = mysqli_connect(
12 'localhost',
13 'root',
14 '',
15 'malastudentskabaza'
16 );
17 if(isset($_POST['kre']))
18 $upit = mysqli_query(
19 $konekcija,
20 "SELECT * from predmet where kredit=".$_POST['kre']
21 );
22 else
23 $upit = mysqli_query(
24 $konekcija,
25 "SELECT * from predmet"
26 );
27 ?>
28 <h1>Predmeti</h1>
29 <form action="" method="post">
30 <input type="number" name="kre">
31 <input type="submit" value="Filter">
32 </form>
33 <table border="1px">
34 <tr>
35 <?php
36 for ($i=0; $i < mysqli_num_fields($upit); $i++) {
37 print '<th>'.mysqli_fetch_field_direct($upit, $i)->name.'</th>';
38 }
39 ?>
40 </tr>
41 <?php
42 while ($vrsta = mysqli_fetch_array($upit)) {
43 print '<tr>';
44 print '<td><a href="zad2.php?podatak='.$vrsta[0].'">'.$vrsta[0].'</a></td>';
45 for ($i=1; $i < mysqli_num_fields($upit); $i++){
46 print '<td>'.$vrsta[$i].'</td>';
47 }
48 print '</tr>';
49 }
50 ?>
51 </table>
52 </body>
53 </html>

http://localhost:4649/?mode=php 1/1
25/01/2019 zad1_07_02.php

1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8" />
5 <meta http-equiv="X-UA-Compatible" content="IE=edge">
6 <title>Page Title</title>
7 <meta name="viewport" content="width=device-width, initial-scale=1">
8 <link rel="stylesheet" type="text/css" media="screen" href="main.css" />
9 <script src="main.js"></script>
10 </head>
11 <body>
12 <?php
13
14 $konekcija = mysqli_connect(
15 'localhost',
16 'root',
17 '',
18 'malastudentskabaza'
19 );
20 if(isset($_POST['pred'])){
21 $ispis="predmet";
22 if(isset($_POST['id'])){
23 $upit = mysqli_query(
24 $konekcija,
25 "INSERT INTO predmet VALUES ('".$_POST['id']."','".$_POST['sifra']."',
'".$_POST['naziv']."', '".$_POST['kredit']."')"
26 );
27 }
28 }
29 else{
30 $ispis="predmet";
31
32 }
33 if(isset($_POST['isp_rok'])){
34 $ispis="ispitni_rok";
35 if(isset($_POST['god_roka'])){
36 $upit = mysqli_query(
37 $konekcija,
38 "INSERT INTO ispitni_rok VALUES
('".$_POST['god_roka']."','".$_POST['ozn_roka']."', '".$_POST['naziv_roka']."')"
39 );
40 }
41 }
42 else {
43 $ispis="predmet";
44 }
45 if($ispis==="predmet"){
46 print '<h1>Predmeti</h1>';
47 }
48 elseif($ispis==="ispitni_rok"){
49 print '<h1>Isptni rokovi</h1>';
50 }
51 else {
52 print '<h1>GRESKA</h1>';
53 }
54 if($ispis==="predmet"){
55 print '<form action="" method="post">';
56 print '<input type="submit" name="isp_rok" value="promjeni">';
57 print '</form>';
58 }
http://localhost:4649/?mode=php 1/2
25/01/2019 zad1_07_02.php

59 if($ispis==="ispitni_rok"){
60 print '<form action="" method="post">';
61 print '<input type="submit" name="pred" value="promjeni">';
62 print '</form>';
63 }
64 $upit = mysqli_query(
65 $konekcija,
66 "SELECT * FROM ".$ispis.""
67 );
68 print '<table border="1px">';
69 print ' <tr>';
70
71 for ($i=0; $i < mysqli_num_fields($upit); $i++) {
72 print '<th>'.mysqli_fetch_field_direct($upit, $i)->name.'</th>';
73 }
74 print ' </tr>';
75
76 while ($vrsta = mysqli_fetch_array($upit)) {
77 print '<tr>';
78 for ($i=0; $i < mysqli_num_fields($upit); $i++){
79 print '<td>'.$vrsta[$i].'</td>';
80 }
81 print '</tr>';
82 }
83 print '</table>';
84 if($ispis==="predmet"){
85 print '<form action="" method="post">';
86 print 'ID <input type="number" name="id" ><br>';
87 print 'Sifra <input type="text" name="sifra" ><br>';
88 print 'Naziv <input type="text" name="naziv" ><br>';
89 print 'Kredit <input type="number" name="kredit" ><br>';
90 print '<input type="submit" name="pred" value="Dodaj">';
91 print '</form>';
92 }
93 if($ispis==="ispitni_rok"){
94 print '<form action="" method="post">';
95 print 'Godina roka <input type="number" name="god_roka" ><br>';
96 print 'Oznaka roka <input type="text" name="ozn_roka" ><br>';
97 print 'Naziv <input type="text" name="naziv_roka" ><br>';
98 print '<input type="submit" name="isp_rok" value="Dodaj">';
99 print '</form>';
100 }
101 ?>
102 </body>
103 </html>

http://localhost:4649/?mode=php 2/2
25/01/2019 zad1_14_06.php

1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8" />
5 <meta http-equiv="X-UA-Compatible" content="IE=edge">
6 <title>Dodaj</title>
7 </head>
8 <body>
9 <?php
10 $konekcija = mysqli_connect(
11 'localhost',
12 'root',
13 '',
14 'malastudentskabaza'
15 );
16 if(isset($_POST['id'])){
17 $upit = mysqli_query(
18 $konekcija,
19 "INSERT INTO `predmet` (`id`, `sifra`, `naziv`, `kredit`) VALUES (".$_POST['id'].",
'".$_POST['sifra']."', '".$_POST['naziv']."', '".$_POST['kredit']."')"
20 );
21 print '<form action="" method="POST">';
22 print 'Unesite ID<input type="number" name="id" value= '.$_POST['id'].' ><br>';
23 print 'Unesite Sifru<input type="text" name="sifra" value= '.$_POST['sifra'].' >
<br>';
24 print 'Unesite Naziv<input type="text" name="naziv" value= '.$_POST['naziv'].'><br>';
25 print 'Unesite Kredit<input type="text" name="kredit" value= '.$_POST['kredit'].'>
<br>';
26 print '<input type="submit" value="Dodaj">';
27 print '</form>';
28
29 print '<form action="zad2_14_06.php" method="POST">';
30 print '<input type="hidden" name="kredit" value= '.$_POST['kredit'].'><br>';
31 print '<input type="submit" value="Krediti">';
32 print '</form>';
33 }
34 else{
35 print '<form action="" method="POST">';
36 print 'Unesite ID<input type="number" name="id" ><br>';
37 print 'Unesite Sifru<input type="text" name="sifra" ><br>';
38 print 'Unesite Naziv<input type="text" name="naziv" ><br>';
39 print 'Unesite Kredit<input type="text" name="kredit" ><br>';
40 print '<input type="submit" value="Dodaj">';
41 print '</form>';
42 }
43 ?>
44 </body>
45 </html>

http://localhost:4649/?mode=php 1/1
25/01/2019 zad1_21_02.php

1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8" />
5 <meta http-equiv="X-UA-Compatible" content="IE=edge">
6 <title>Spisak studenata koji su pali</title>
7 </head>
8 <body>
9 <?php
10 $konekcija = mysqli_connect(
11 'localhost',
12 'root',
13 '',
14 'malastudentskabaza'
15 );
16 if(isset($_POST['god_roka'])){
17 $upit = mysqli_query(
18 $konekcija,
19 "SELECT DISTINCT(dosije.indeks), ime, prezime, ocena, ispit.godina_roka ,
ispit.oznaka_roka from ispit join ispitni_rok on
ispit.godina_roka=ispitni_rok.godina_roka join dosije on dosije.indeks=ispit.indeks
where ispit.godina_roka=".$_POST['god_roka']." and
ispit.oznaka_roka='".$_POST['ozn_roka']."' and ocena=5"
20 );
21 if (mysqli_num_rows($upit)==0) {
22 print "<h1>Niko nije pao u ovom roku.</h1><br>";
23 goto prazno;
24 }
25 print '<h1>Studenti koji su pali</h1>';
26 print '<table border="1px">';
27 print '<tr>';
28 for ($i=0; $i < mysqli_num_fields($upit); $i++) {
29 print '<th>'.mysqli_fetch_field_direct($upit, $i)->name.'</th>';
30 }
31 print '</tr>';
32 while ($vrsta = mysqli_fetch_array($upit)) {
33 print '<tr>';
34 print '<td><a href="zad2_21_02.php?podatak='.$vrsta[0].'">'.$vrsta[0].'</a>
</td>';
35 for ($i=1; $i < mysqli_num_fields($upit); $i++){
36 print '<td>'.$vrsta[$i].'</td>';
37 }
38 print '</tr>';
39 }
40 prazno:
41 }
42 print '</table>';
43 print '<form action="" method="post">';
44 print 'Unesite godinu roka <input type="number" name="god_roka" ><br>';
45 print 'Unesite oznaku roka <input type="text" name="ozn_roka" ><br>';
46 print '<input type="submit" value="Pretrazi">';
47 print '</form>';
48 ?>
49 </body>
50 </html>

http://localhost:4649/?mode=php 1/1
25/01/2019 zad1_25_04.php

1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8" />
5 <meta http-equiv="X-UA-Compatible" content="IE=edge">
6 <title>Spisak predmeta</title>
7 </head>
8 <body>
9 <?php
10 $konekcija = mysqli_connect(
11 'localhost',
12 'root',
13 '',
14 'malastudentskabaza'
15 );
16 if(isset($_GET['sortiranje'])){
17 $upit = mysqli_query(
18 $konekcija,
19 "SELECT id, naziv FROM predmet ORDER BY ".$_GET['sortiranje']." DESC;"
20 );
21 }
22 else{
23 $upit = mysqli_query(
24 $konekcija,
25 "SELECT id, naziv FROM `predmet`"
26
27 );
28 }
29 print '<h1>Predmeti</h1>';
30 print '<table border="1px">';
31 print '<tr>';
32 for ($i=0; $i < mysqli_num_fields($upit); $i++) {
33 $sta=''.mysqli_fetch_field_direct($upit, $i)->name.'';
34 print '<th>'.$sta;
35 print '<form action="" method="GET">';
36 print '<input type="hidden" name="sortiranje" value="'.$sta.'">';
37 print '<input type="submit" value="Sortiraj">';
38 print '</form>';
39 print '</th>';
40 }
41 print '</tr>';
42 while ($vrsta = mysqli_fetch_array($upit)) {
43 print '<tr>';
44 print '<td><a href="zad2_25_04.php?podatak='.$vrsta[0].'">'.$vrsta[0].'</a>
</td>';
45 for ($i=1; $i < mysqli_num_fields($upit); $i++){
46 print '<td>'.$vrsta[$i].'</td>';
47 }
48 print '</tr>';
49 }
50 print '</table>';
51 ?>
52 </body>
53 </html>

http://localhost:4649/?mode=php 1/1
25/01/2019 zad2.php

1 Sa casa 2...
2 <!DOCTYPE html>
3 <html>
4 <head>
5 <meta charset="utf-8" />
6 <meta http-equiv="X-UA-Compatible" content="IE=edge">
7 <title>Studenti</title>
8 </head>
9 <body>
10 <?php
11 $konekcija = mysqli_connect(
12 'localhost',
13 'root',
14 '',
15 'malastudentskabaza'
16 );
17 if(isset($_POST['ocena']))
18 $upit = mysqli_query(
19 $konekcija,
20 'UPDATE ispit Set ocena='.$_POST['ocena'].' where indeks='.$_POST['indeks'].'
and id_predmet='.$_GET['podatak']
21 );
22 $upit = mysqli_query(
23 $konekcija,
24 "SELECT dosije.indeks, ime, prezime, ocena from predmet join ispit on
id=id_predmet join dosije on dosije.indeks=ispit.indeks where id=".$_GET['podatak']
25 );
26 ?>
27 <h1>Studenti</h1>
28 <table border="1px">
29 <tr>
30 <?php
31 for ($i=0; $i < mysqli_num_fields($upit); $i++) {
32 print '<th>'.mysqli_fetch_field_direct($upit, $i)->name.'</th>';
33 }
34 ?>
35 </tr>
36 <?php
37 while ($vrsta = mysqli_fetch_array($upit)) {
38 print '<tr>';
39 for ($i=0; $i < mysqli_num_fields($upit)-1; $i++){
40 print '<td>'.$vrsta[$i].'</td>';
41 }
42 print '<td>';
43 print '<form action="" method="post">';
44 print '<input style="display:none;" type="number" name="indeks"
value="'.$vrsta[0].'">';
45 print '<input type="number" name="ocena" value="'.$vrsta[3].'">';
46 print '<input type="submit" value="Izvrsi">';
47 print '</form>';
48 print '</td>';
49 print '</tr>';
50 }
51 ?>
52 </table>
53 </body>
54 </html>

http://localhost:4649/?mode=php 1/1
25/01/2019 zad2_14_06.php

1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8" />
5 <meta http-equiv="X-UA-Compatible" content="IE=edge">
6 <title>Dodaj</title>
7 </head>
8 <body>
9 <?php
10 $konekcija = mysqli_connect(
11 'localhost',
12 'root',
13 '',
14 'malastudentskabaza'
15 );
16 if(isset($_POST['obrisi'])){
17 print $_POST['obrisi'];
18 $upit = mysqli_query(
19 $konekcija,
20 "DELETE from predmet where id=".$_POST['obrisi']." "
21 );
22 }
23 if(isset($_POST['kredit'])){
24
25 $upit = mysqli_query(
26 $konekcija,
27 "SELECT * FROM `predmet` where kredit = '".$_POST['kredit']."'"
28 );
29 }
30 else{
31 Print "<h1>GRESKA</h1>";
32 return 0;
33 }
34 print '<table border="1px">';
35 print ' <tr>';
36 for ($i=0; $i < mysqli_num_fields($upit); $i++) {
37 print '<th>'.mysqli_fetch_field_direct($upit, $i)->name.'</th>';
38 }
39 print ' </tr>';
40 while ($vrsta = mysqli_fetch_array($upit)) {
41 print '<tr>';
42 for ($i=0; $i < mysqli_num_fields($upit); $i++){
43 print '<td>'.$vrsta[$i].'</td>';
44 }
45 print '<td>';
46 print '<form action="" method="POST">';
47 print '<input type="hidden" name="obrisi" value="'.$vrsta[0].'">';
48 print '<input type="hidden" name="kredit" value= "'.$vrsta[3].'">';
49 print '<input type="submit" value="Obrisite">';
50 print '</form>';
51 print '</td>';
52 print '</tr>';
53 }
54 print '</table>';
55 ?>
56 </body>
57 </html>

http://localhost:4649/?mode=php 1/1
25/01/2019 zad2_21_02.php

1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8" />
5 <meta http-equiv="X-UA-Compatible" content="IE=edge">
6 <title>Page Title</title>
7 <meta name="viewport" content="width=device-width, initial-scale=1">
8 <link rel="stylesheet" type="text/css" media="screen" href="main.css" />
9 <script src="main.js"></script>
10 </head>
11 <body>
12 <?php
13 $konekcija = mysqli_connect(
14 'localhost',
15 'root',
16 '',
17 'malastudentskabaza'
18 );
19 echo '<a href="zad1_21_02.php"><h1>Nazad</h1></a>';
20 if(isset($_POST['indeks'])){
21 $upit = mysqli_query(
22 $konekcija,
23 "DELETE from ispit where indeks=".$_POST['indeks']." AND
id_predmet=".$_POST['id']." AND godina_roka=".$_POST['god']." AND
oznaka_roka='".$_POST['ozn']."'"
24 );
25 }
26 $upit = mysqli_query(
27 $konekcija,
28 "SELECT * from ispit where indeks=".$_GET['podatak']
29 );
30 print '<table border="1px">';
31 print ' <tr>';
32 for ($i=0; $i < mysqli_num_fields($upit); $i++) {
33 print '<th>'.mysqli_fetch_field_direct($upit, $i)->name.'</th>';
34 }
35 print '<th>Brisanje</th>';
36 print ' </tr>';
37 while ($vrsta = mysqli_fetch_array($upit)) {
38 print '<tr>';
39 for ($i=0; $i < mysqli_num_fields($upit); $i++){
40 print '<td>'.$vrsta[$i].'</td>';
41 }
42 print '<td>';
43 print '<form action="" method="post">';
44 print '<input type="hidden" name="indeks" value="'.$vrsta[0].'">';
45 print '<input type="hidden" name="id" value="'.$vrsta[1].'">';
46 print '<input type="hidden" name="god" value="'.$vrsta[2].'">';
47 print '<input type="hidden" name="ozn" value="'.$vrsta[3].'">';
48 print '<input type="submit" value="Obrisite">';
49 print '</form>';
50 print '</td>';
51 print '</tr>';
52 }
53 print '</table>'
54 ?>
55 </body>
56 </html>

http://localhost:4649/?mode=php 1/1
25/01/2019 zad2_25_04.php

1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8" />
5 <meta http-equiv="X-UA-Compatible" content="IE=edge">
6 <title>Studenti koji nisu polozili</title>
7 </head>
8 <body>
9 <?php
10 $konekcija = mysqli_connect(
11 'localhost',
12 'root',
13 '',
14 'malastudentskabaza'
15 );
16 echo '<a href="zad1_25_04.php"><h1>Nazad</h1></a>';
17 if(isset($_POST['indeks'])){
18 $upit = mysqli_query(
19 $konekcija,
20 "UPDATE ispit SET ocena = 6 WHERE ispit.indeks =".$_POST['indeks']." AND
ispit.id_predmet =".$_POST['idpredmeta']." "
21
22 );
23 }
24 if(isset($_GET['podatak'])){
25 $upit = mysqli_query(
26 $konekcija,
27 "SELECT * FROM `ispit` where id_predmet=".$_GET['podatak']." AND ocena=5"
28 );
29 }
30 else{
31 print "<H1> GRESKA </H1>";
32 return 0;
33
34 }
35 print '<h1>Predmeti</h1>';
36 print '<table border="1px">';
37 print '<tr>';
38 for ($i=0; $i < mysqli_num_fields($upit); $i++) {
39 print '<th>'.mysqli_fetch_field_direct($upit, $i)->name.'</th>';
40 }
41 print '</tr>';
42 while ($vrsta = mysqli_fetch_array($upit)) {
43 print '<tr>';
44 for ($i=0; $i < mysqli_num_fields($upit); $i++){
45 print '<td>'.$vrsta[$i].'</td>';
46 }
47 print '<td><form action="" method="post">';
48 print '<input type="hidden" name="indeks" value="'.$vrsta[0].'">';
49 print '<input type="hidden" name="idpredmeta" value="'.$vrsta[1].'">';
50 print '<input type="submit" value="Polozi"</td>';
51 print '</tr>';
52 print '</tr>';
53 }
54 print '</table>';
55 ?>
56 </body>
57 </html>

http://localhost:4649/?mode=php 1/1

Das könnte Ihnen auch gefallen