sueckreimir

uceniciMVC/index

Oct 9th, 2019 (edited)
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.42 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.         class model
  16.         {
  17.             function pohranaPodataka()
  18.             {
  19.                 require 'konekcija.php';
  20.                 if(isset($_GET['broj']))
  21.                 {
  22.                     $broj=$_GET['broj'];
  23.                     $pocetno=($broj-1)*15;
  24.                     $y=($broj-1)*15;
  25.                 }
  26.                 else
  27.                 {
  28.                     $broj=1;
  29.                     $pocetno=0;
  30.                     $y=0;
  31.                 }
  32.                 $query="select imeStud,prezStud,mbrStud
  33.                from stud
  34.                limit $pocetno,15";
  35.                 $result= mysqli_query($link,$query);
  36.                 while($row=mysqli_fetch_assoc($result))
  37.                 {
  38.                     $pod[]=array('imeStud'=>$row['imeStud'],
  39.                                 'prezStud'=>$row['prezStud'],
  40.                                  'mbrStud'=>$row['mbrStud']);
  41.                 }
  42.                 $query2="select imeStud,prezStud,mbrStud
  43.                from stud";
  44.                 $result2=mysqli_query($link,$query2);
  45.                 $numRows= mysqli_num_rows($result2);
  46.                 $total=ceil($numRows/15);
  47.                
  48.                
  49.                
  50.                 $podaci=array('pod'=>$pod,
  51.                                 'y'=>$y,
  52.                             'total'=>$total,
  53.                              'broj'=>$broj);
  54.                 return $podaci;
  55.                
  56.                
  57.             }
  58.         }
  59.        
  60.         class  view
  61.         {
  62.             function ispisPodataka($podaci)
  63.             {
  64.                 echo '<center>';
  65.                 echo '<a href="https://kresosusec.com.hr">'.'Početna'.'</a>'.'<br>';
  66.                 echo '<table border="2">';
  67.                 echo '<tr><th>'.' '.'<th>'.
  68.                               'Ime'.'<th>'.
  69.                           'Prezime'.'<th>'.
  70.                               'MBR'.'<tr>';
  71.                
  72.                
  73.                 foreach($podaci['pod'] as $key=>$val)
  74.                 {
  75.                     $mbr='<a href="uredi.php?mbr='.$val['mbrStud'].
  76.                     '&broj='.$podaci['broj'].'">'.$val['mbrStud'].'</a>';
  77.                     $podaci['y']=$podaci['y']+1;
  78.                     echo '<tr><td>'.$podaci['y'].'<td>'.
  79.                                     $val['imeStud'].'<td>'.
  80.                                     $val['prezStud'].'<td>'.
  81.                                     $mbr.'<tr>';
  82.                 }
  83.                 echo '</table>';
  84.                
  85.                 if($podaci['broj']<$podaci['total'])
  86.                 {
  87.                     echo '<a href="index.php?broj='.($podaci['broj']+1).'">'.
  88.                     'Naprijed'.'</a>'.'<br>';
  89.                 }
  90.                 else
  91.                 {
  92.                     echo '<a href="index.php">'.'Naprijed'.'</a>'.'<br>';
  93.                 }
  94.                
  95.                 for($x=1;$x<=$podaci['total'];$x=$x+1)
  96.                 {
  97.                     echo '<a href="index.php?broj='.$x.'">'.$x.'</a>|';
  98.                 }
  99.                
  100.                 if($podaci['broj']>1)
  101.                 {
  102.                     echo '<br>'.'<a href="index.php?broj='.($podaci['broj']-1).'">'.
  103.                     'Natrag'.'</a>'.'<br>';
  104.                 }
  105.                 else
  106.                 {
  107.                     echo '<br>'.'<a href="index.php">'.'Natrag'.'</a>'.'<br>';
  108.                 }
  109.                
  110.                
  111.                
  112.                
  113.             }
  114.         }
  115.        
  116.         class controler
  117.         {
  118.             public $_Model;
  119.             public $_view;
  120.            
  121.             function __construct()
  122.             {
  123.                 $this->_Model=new model();
  124.                 $this->_view=new view();
  125.             }
  126.            
  127.             function start()
  128.             {
  129.                 $podaci= $this->_Model->pohranaPodataka();
  130.                 $this->_view->ispisPodataka($podaci);
  131.             }
  132.         }
  133.        
  134.        
  135.         $pokreni=new controler();
  136.         $pokreni->start();
  137.         // put your code here
  138.        
  139.         ?>
  140.     </body>
  141.    
  142. </html>
Add Comment
Please, Sign In to add comment