sueckreimir

dvoraneMVC/index

Oct 9th, 2019 (edited)
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.36 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.         class model
  15.         {
  16.             function pohranaPodataka()
  17.             {
  18.                 require 'konekcija.php';
  19.                 $query="select oznDvorana, kapacitet
  20.                from dvorana";
  21.                 $result= mysqli_query($link, $query);
  22.                 while($row= mysqli_fetch_assoc($result))
  23.                 {
  24.                     $pod[]=array('oznDvorana'=>$row['oznDvorana'],
  25.                                   'kapacitet'=>$row['kapacitet']);
  26.                 }
  27.                 $podaci=$pod;
  28.                 return $podaci;
  29.             }
  30.            
  31.         }    
  32.        
  33.         class view
  34.         {
  35.             function ispisPodataka($podaci)
  36.             {
  37.                 echo '<a href="https://kresosusec.com.hr">'.'Početna'.'</a>';
  38.                 echo '<table border="2">';
  39.                 echo '<tr><th>'.' '.'<th>'.
  40.                           'Dvorana'.'<th>'.
  41.                         'Kapacitet'.'<tr>';
  42.                 $x=0;
  43.                 foreach($podaci as $key=>$val)
  44.                 {
  45.                     $x=$x+1;
  46.                     $dvorana='<a href="rezervacija.php?dvorana='.$val['oznDvorana'].
  47.                     '">'.$val['oznDvorana'].'</a>';
  48.                     echo '<tr><td>'.$x.'<td>'.
  49.                                     $dvorana.'<td>'.
  50.                                     $val['kapacitet'].'<tr>';
  51.                 }
  52.                 echo '<table>';
  53.             }
  54.         }
  55.        
  56.        
  57.         class controler
  58.         {
  59.             public $_Model;
  60.             public $_View;
  61.            
  62.             function __construct()
  63.             {
  64.                 $this->_Model=new model();
  65.                 $this->_View=new view();
  66.             }
  67.            
  68.             function start()
  69.             {
  70.                 $podaci= $this->_Model->pohranaPodataka();
  71.                 $this->_View->ispisPodataka($podaci);
  72.             }
  73.         }
  74.        
  75.        
  76.         $pokreni=new controler();
  77.         $pokreni->start();
  78.        
  79.        
  80.         ?>
  81.     </body>
  82.    
  83.    
  84. </html>
Add Comment
Please, Sign In to add comment