Advertisement
sueckreimir

prosjekMVC/predmeti

Jul 10th, 2022
1,077
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.41 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.                
  21.                 if(isset($_GET['mbr']))
  22.                 {
  23.                     $mbr=$_GET['mbr'];
  24.                     $prosjek=$_GET['prosjek'];
  25.                 }
  26.                 else
  27.                 {
  28.                     header('location:index.php');
  29.                 }
  30.                
  31.                 $query="select p.nazPred,o.ocjena
  32.                from ocjene o
  33.                left outer join pred p
  34.                on o.sifPred=p.sifPred
  35.                where o.mbrStud=$mbr";
  36.                 $result=mysqli_query($link,$query);
  37.                
  38.                 while($row=mysqli_fetch_assoc($result))
  39.                 {
  40.                     $pod[]=array( 'ocjena'=>$row['ocjena'],
  41.                                  'nazPred'=>$row['nazPred']);
  42.                                  
  43.                 }
  44.                
  45.                 $query2="select imeStud,prezStud from ucenici
  46.                where mbrStud=$mbr";
  47.                 $result2=mysqli_query($link,$query2);
  48.                 $fetch=mysqli_fetch_assoc($result2);
  49.                 $x=0;
  50.                
  51.                 $p=array('pod'=>$pod,
  52.                        'mbr'=>$mbr,
  53.                    'prosjek'=>$prosjek,
  54.                      'fetch'=>$fetch,
  55.                          'x'=>$x);
  56.                          
  57.                 return $p;
  58.             }
  59.            
  60.         }
  61.        
  62.         class view
  63.         {
  64.             function ispisPodataka($p)
  65.             {
  66.                echo '<a href="index.php">'.'Natrag'.'</a>'.'<br>';
  67.                
  68.                echo '<table border="0">'.
  69.                     '<tr><td>'.'Ime:'.'<td>'.$p['fetch']['imeStud'].'<tr>'.
  70.                     '<tr><td>'.'Prezime:'.'<td>'.$p['fetch']['prezStud'].'<tr>'.
  71.                     '<tr><td>'.'Prosjek:'.'<td>'.$p['prosjek'].'<tr>'.
  72.                     '</table>';
  73.                echo '<table border="2">';
  74.                echo '<tr><th>'.''.'<th>'.'Predavanje'.'<th>'.'Ocjena'.'<tr>';
  75.                
  76.                
  77.                foreach($p['pod'] as $key=>$val)
  78.                {
  79.                   $p['x']=$p['x']+1;
  80.                    echo '<tr><td>'.$p['x'].'<td>'.
  81.                                    $val['nazPred'].'<td>'.
  82.                                    $val['ocjena'].'<tr>';
  83.                    
  84.                }
  85.                echo '</table>';
  86.             }
  87.            
  88.         }
  89.        
  90.         class controler
  91.         {
  92.             public $_Model;
  93.             public $_View;
  94.            
  95.             function __construct()
  96.             {
  97.                 $this->_Model=new model();
  98.                 $this->_View=new view();
  99.             }
  100.            
  101.             function start()
  102.             {
  103.                 $p= $this->_Model->pohranaPodataka();
  104.                 $this->_View->ispisPodataka($p);
  105.             }
  106.        
  107.         }
  108.        
  109.        
  110.         $pokreni=new controler();
  111.         $pokreni->start();
  112.         ?>
  113.     </body>
  114.    
  115.  
  116. </html>
  117.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement