Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <!--
- 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.
- -->
- <html>
- <head>
- <meta charset="UTF-8">
- <title></title>
- </head>
- <body>
- <?php
- class model
- {
- function pohrabaPodataka()
- {
- require 'konekcija.php';
- if(isset($_GET['dvorana']))
- {
- $dvorana=$_GET['dvorana'];
- $query="select r.oznDvorana,r.oznVrstaDan,r.sat,p.nazPred
- from rezervacija r
- left outer join pred p
- on r.sifPred=p.sifPred
- where r.oznDvorana='$dvorana'
- order by case r.oznVrstaDan
- when 'PO' then 1
- when 'UT' then 2
- when 'SR' then 3
- when 'CE' then 4
- when 'PE' then 5
- end,r.sat";
- $result=mysqli_query($link,$query);
- $numRows= mysqli_num_rows($result);
- while($row=mysqli_fetch_assoc($result))
- {
- $pod[]=array('oznDvorana'=>$row['oznDvorana'],
- 'oznVrstaDan'=>$row['oznVrstaDan'],
- 'sat'=>$row['sat'],
- 'nazPred'=>$row['nazPred']);
- }
- if($numRows==null)
- {
- $pod=true;
- }
- $podaci=array('pod'=>$pod,
- 'numRows'=>$numRows,
- 'dvorana'=>$dvorana);
- return $podaci;
- }
- else
- {
- header('location:index.php');
- }
- }
- }
- class view
- {
- function ispisPodataka($podaci)
- {
- if($podaci['numRows']==0)
- {
- echo '<a href="index.php">'.'<i>'.'Natrag'.'</i>'.'</a>'.'<br>';
- echo 'Za biranu dvoranu '.'<i><b>'.$podaci['dvorana'].'</i></b>'
- .' nema rezerviranih termina'.'<br>';
- }
- else
- {
- echo '<a href="index.php">'.'<i>'.'Natrag'.'</i>'.'</a>'.'<br>';
- echo '<table border="2">';
- echo '<tr><th>'.' '.'<th>'.
- 'Dvorana'.'<th>'.
- 'Dan'.'<th>'.
- 'Vrijeme'.'<th>'.
- 'Predavanje'.'<tr>';
- $x=0;
- foreach($podaci['pod'] as $key=>$val)
- {
- switch($val['oznVrstaDan'])
- {
- case 'PO':
- $dan='Ponedjeljak';
- break;
- case 'UT':
- $dan='Utorak';
- break;
- case 'SR':
- $dan='Srijeda';
- break;
- case 'CE':
- $dan='Četvrtak';
- break;
- case 'PE':
- $dan='Petak';
- break;
- default :
- $dan=$val['oznVrstaDan'];
- break;
- }
- $x=$x+1;
- echo '<tr><td>'.$x.'<td>'.
- $val['oznDvorana'].'<td>'.
- $dan.'<td>'.
- vrijeme($val['sat']).'<td>',
- $val['nazPred'].'<tr>';
- }
- echo '</table>';
- }
- }
- }
- class controler
- {
- public $_Model;
- public $_View;
- function __construct()
- {
- $this->_Model=new model();
- $this->_View=new view();
- }
- function start()
- {
- $podaci= $this->_Model->pohrabaPodataka();
- $this->_View->ispisPodataka($podaci);
- }
- }
- $pokreni=new controler();
- $pokreni->start();
- #prostor za funkcija
- function vrijeme($subject)
- {
- if($subject<10)
- {
- $subject='0'.$subject.':00';
- }
- else
- {
- $subject=$subject.':00';
- }
- return $subject;
- }
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment