Advertisement
sueckreimir

ispitMVC

Oct 8th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.86 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>Kreso</title>
  11.     </head>
  12.     <body>
  13.         <?php
  14.        
  15.         class model
  16.         {
  17.             function pohranaPodataka()
  18.             {
  19.                 require 'data.php';
  20.                 $podaci=$data;
  21.                 return $podaci;
  22.             }
  23.            
  24.            
  25.         }
  26.        
  27.         class view
  28.         {
  29.             function ispisPodataka($podaci)
  30.             {
  31.                 echo '<a href="https://kresosusec.com.hr">'.'Početna'.'</a>';
  32.                 echo '<table border="2">';
  33.                 echo '<tr><td>'.' '.'<td>'.
  34.                               'Ime'.'<td>'.
  35.                           'Prezime'.'<td>'.
  36.                             'Datum'.'<td>'.
  37.                           'Placeno'.'<tr>';
  38.                
  39.                 foreach($podaci as $key=>$val)
  40.                 {
  41.                     echo '<tr><td>'.$key.'<td>'.
  42.                                     $val['ime'].'<td>'.
  43.                                     $val['prezime'].'<td>'.
  44.                                     datum($val['datum']).'<td>';
  45.                     echo '<select>';
  46.                     if($val['placeno']=='Da')
  47.                     {
  48.                         echo '<option>'.'Da'.'</option>';
  49.                         echo '<option>'.'Ne'.'</option>';
  50.                     }
  51.                     elseif($val['placeno']=='Ne')
  52.                     {
  53.                         echo '<option>'.'Ne'.'</option>';
  54.                         echo '<option>'.'Da'.'</option>';
  55.                     }
  56.                     else
  57.                     {
  58.                         echo '<option>'.'Greska'.'</option>';
  59.                     }
  60.                    
  61.                     echo '</select>';
  62.                 }
  63.                
  64.                 echo '</table>';
  65.             }
  66.         }
  67.        
  68.         class controler
  69.         {
  70.             public $_Model;
  71.             public $_View;
  72.            
  73.             function __construct()
  74.             {
  75.                 $this->_Model=new model();
  76.                 $this->_View=new view();
  77.             }
  78.            
  79.             function start()
  80.             {
  81.                 $podaci= $this->_Model->pohranaPodataka();
  82.                 $this->_View->ispisPodataka($podaci);
  83.             }
  84.         }
  85.        
  86.         $pokreni=new controler();
  87.         $pokreni->start();
  88.        
  89.         #prostor za funkcije
  90.        function datum($subject)
  91.         {
  92.             $delimiter='/[-]/';
  93.             $polje= preg_split($delimiter, $subject);
  94.             return $polje[2].' '.$polje[1].' '.$polje[0];
  95.         }
  96.         ?>
  97.     </body>
  98. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement