Advertisement
sueckreimir

dvorane/rezervacija

Sep 24th, 2019
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.49 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <!--
  3. To change this license header, choose License Headers in Project Properties.
  4. To change this template file, choose Tools | Templates
  5. and open the template in the editor.
  6. -->
  7. <html>
  8.     <head>
  9.         <meta charset="UTF-8">
  10.         <title></title>
  11.     </head>
  12.     <body>
  13.         <?php
  14.        
  15.         require 'konekcija.php';
  16.        
  17.         if(isset($_GET['dvorana']))
  18.         {
  19.             $dvorana=$_GET['dvorana'];
  20.            
  21.             $query="select r.oznDvorana,r.oznVrstadan,r.sat,p.nazPred
  22.            from rezervacija r
  23.                 left outer join pred p
  24.                 on p.sifPred=r.sifPred
  25.            where r.ozndvorana='$dvorana'
  26.            order by case r.oznvrstaDan
  27.            when 'PO' then 1
  28.            when 'UT' then 2
  29.            when 'SR' then 3
  30.            when 'CE' then 4
  31.            when 'PE' then 5
  32.            when 'SU' then 6
  33.            when 'NE' then 7
  34.            end,r.sat";
  35.            
  36.             $result= mysqli_query($link, $query);
  37.             $numRows= mysqli_num_rows($result);
  38.            
  39.             if($numRows==0)
  40.             {
  41.                 echo '<a href="index.php">'.'<i><b>'.'Natrag'.'</i></b>'.'</a>'.'<br>';
  42.                 echo 'Za trazenu dvoranu naziva '.'<i><b>'.$dvorana.'</i></b>'
  43.                 .' nema rezerviranih termina'.'<br>';
  44.             }
  45.             else
  46.             {
  47.                 echo '<a href="index.php">'.'<i><b>'.'Natrag'.'</i></b>'.'</a>'.'<br>';
  48.                 echo '<table border="2">';
  49.                 echo '<tr><th>'.''.'<th>'.
  50.                          'Dvorana'.'<th>'.
  51.                              'Dan'.'<th>'.
  52.                          'Vrijeme'.'<th>'.
  53.                       'Predavanje'.'<tr>';
  54.                  
  55.                  $x=0;
  56.                  while($row= mysqli_fetch_assoc($result))
  57.                  {
  58.                      switch($row['oznVrstadan'])
  59.                      {
  60.                          case 'PO':
  61.                              $dan='Ponedjeljak';
  62.                              break;
  63.                          case 'UT':
  64.                              $dan='Utorak';
  65.                              break;
  66.                          case 'SR':
  67.                              $dan='Srijeda';
  68.                              break;
  69.                          case 'CE':
  70.                              $dan='Četvrtak';
  71.                              break;
  72.                          case 'PE':
  73.                              $dan='Petak';
  74.                              break;
  75.                          default:
  76.                              $dan=$row['oznVrstadan'];
  77.                          
  78.                      }
  79.                     $x=$x+1;
  80.                     echo '<tr><td>'.$x.'<td>'.
  81.                                     $row['oznDvorana'].'<td>'.
  82.                                     $dan.'<td>'.
  83.                                     vrijeme($row['sat']).'<td>'.
  84.                                     $row['nazPred'].'<tr>';
  85.                  }
  86.             }
  87.            
  88.             echo '</table>';
  89.            
  90.            
  91.            
  92.            
  93.            
  94.         }
  95.         #ako se pristupa bez superglobale u linku
  96.        else
  97.         {
  98.             header('location:index.php');
  99.         }
  100.        
  101.         #prostor za funkcije
  102.         function vrijeme($subject)
  103.             {
  104.                 $novo= mktime($subject,0);
  105.                 return date('H:i',$novo);
  106.             }
  107.        
  108.        
  109.         ?>
  110.     </body>
  111. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement