Advertisement
sueckreimir

zupanija

Sep 24th, 2019
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.70 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.         echo '<a href="http://kresosusec.com.hr">'.'Početna'.'</a>'.'<br>';
  16.        
  17.         require 'konekcija.php';
  18.        
  19.         $abeceda=array('A','B','C','Č','Ć','D','Dž','E','F','G','H','I','J','K',
  20.         'L','Lj','M','N','Nj','O','P','R','S','Š','T','U','V','Z','Ž');
  21.        
  22.         foreach($abeceda as $key=>$val)
  23.         {
  24.             echo '<a href="index.php?slovo='.$val.'">'.$val.'</a>|';
  25.         }
  26.        
  27.         if(isset($_GET['slovo']))
  28.         {
  29.             $slovo=$_GET['slovo'];
  30.            
  31.             $query="select m.nazMjesto,z.nazZupanija,
  32.            sum(case when m.pbr=s.pbrRod then 1 else 0 end) as rodjenih,
  33.            sum(case when m.pbr=s.pbrStan then 1 else 0 end) as stanuju,
  34.            max(floor(datediff(now(),s.datRodStud)/365.25)) as najstariji,
  35.            min(floor(datediff(now(),s.datRodStud)/365.25)) as najmladji
  36.            from mjesto m
  37.                 left outer join zupanija z
  38.                 on m.sifZupanija=z.sifZupanija
  39.                 left outer join stud s
  40.                 on m.pbr=s.pbrRod or m.pbr=s.pbrStan
  41.            where m.nazMjesto like '$slovo%'    
  42.            group by m.nazMjesto,z.nazZupanija
  43.            order by m.nazMjesto";
  44.            
  45.             $result= mysqli_query($link, $query);
  46.             $numRows= mysqli_num_rows($result);
  47.            
  48.             if($numRows==0)
  49.             {
  50.                 echo '<br>'.'Za birano slovo '.'<b><i>'.$slovo.'</b></i>'.
  51.                 ' nema nikakvih rezultata'.'<br>';
  52.             }
  53.             else
  54.             {
  55.                 echo '<br>';
  56.                 echo '<table border="2">';
  57.                 echo '<tr><th>'.' '.'<th>'.
  58.                            'Mjesto'.'<th>'.
  59.                          'Županija'.'<th>'.
  60.                           'Rođenih'.'<th>'.
  61.                           'Stanuju'.'<th>'.
  62.                        'Najstariji'.'<th>'.
  63.                          'Najmlađi'.'<tr>';
  64.                
  65.                 $x=0;
  66.                 while($row= mysqli_fetch_assoc($result))
  67.                 {
  68.                     switch($row['najstariji'])
  69.                     {
  70.                         case NULL:
  71.                             $najstariji=0;
  72.                             break;
  73.                         default:
  74.                             $najstariji=$row['najstariji'];
  75.                             break;
  76.                     }
  77.                     switch($row['najmladji'])
  78.                     {
  79.                         case NULL:
  80.                             $najmladji=0;
  81.                             break;
  82.                         default :
  83.                             $najmladji=$row['najmladji'];
  84.                             break;
  85.                     }
  86.                     $x=$x+1;
  87.                     echo '<tr><td>'.$x.'<td>'.
  88.                                     $row['nazMjesto'].'<td>'.
  89.                                     $row['nazZupanija'].'<td>'.
  90.                                     $row['rodjenih'].'<td>'.
  91.                                     $row['stanuju'].'<td>'.
  92.                                     $najstariji.'<td>'.
  93.                                     $najmladji.'<tr>';
  94.                 }
  95.                 echo '</table>';
  96.             }
  97.         }
  98.         else
  99.         {
  100.             echo '<br>'.'Odaberi neko slovo'.'<br>';
  101.         }
  102.        
  103.        
  104.         ?>
  105.        
  106.     </body>
  107. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement