-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnajmovi.php
50 lines (48 loc) · 1.44 KB
/
najmovi.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
<?php
require('nav.php');
require ('baza.php');
$sql = "SELECT N.datum_pocetka, N.datum_zavrsetka, N.broj_sati * A.cijena_po_satu as cijena, CONCAT(MA.naziv, ' ', A.naziv) as automobil,
CONCAT(K.ime, ' ', K.prezime) as imePrezime from najam N JOIN automobil A JOIN korisnik K JOIN marka_automobila MA
WHERE N.automobil_id = A.id AND N.korisnik_id = K.id AND MA.id = A.marka_id";
if ($_SESSION["role"] == "kupac") {
$sql .= " AND K.id=" . $_SESSION["user"];
}
$result = $con->query($sql)->fetch_all(MYSQLI_ASSOC);
?>
<body>
<div class="container">
<div class="row">
<div class="col">
<?php if (count($result)): ?>
<table class="table table-hover table-dark mt-5">
<thead>
<tr>
<th>Korisnik</th>
<th>Automobil</th>
<th>Cijena (KM)</th>
<th>Datum početka</th>
<th>Datum završetka</th>
</tr>
</thead>
<tbody>
<?php
foreach ($result as $res):
?>
<tr>
<td><?= $res["imePrezime"] ?></td>
<td><?= $res["automobil"] ?></td>
<td><?= $res["cijena"] ?></td>
<td><?= $res["datum_pocetka"] ?></td>
<td><?= $res["datum_zavrsetka"] ?></td>
</tr>
<?php endforeach ?>
</tbody>
</table>
<?php else: ?>
<p class="mt-5 text-center">Nema najmova</p>
<?php endif; ?>
</div>
</div>
</div>
<?php require('footer.php')?>
</html>