Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Document</title>
- </head>
- <body>
- <?php
- $path = './randomdata.csv';
- if(isset($_GET['a'])) {
- $a = $_GET['a'];
- }
- else {
- $a = '';
- }
- switch($a){
- case 'pregled': pregled();break;
- default: ispis();
- }
- function ispis(){
- $slova=array();
- global $path;
- $sadrzaj = file($path);
- foreach($sadrzaj as $s){
- $redak = explode("|",$s);
- if(!in_array(substr($redak[4],0,1),$slova)){
- array_push($slova,substr($redak[4],0,1));
- }
- }
- unset($slova[0]);
- sort($slova);
- foreach($slova as $s){
- echo '<a href="?a=pregled&slovo='.$s.'">'.$s.'</a><br>';
- }
- }
- function pregled(){
- $slovo=$_GET['slovo'];
- global $path;
- $sadrzaj = file($path);
- echo '<table border=1>';
- foreach($sadrzaj as $s){
- echo '<tr>';
- $redak = explode("|",$s);
- if(substr($redak[4],0,1)==$slovo){
- echo '<td>'.$redak[0].'</td>';
- echo '<td>'.$redak[1].'</td>';
- echo '<td>'.$redak[2].'</td>';
- echo '<td>'.$redak[3].'</td>';
- echo '<td>'.$redak[4].'</td>';
- echo '<td>'.$redak[5].'</td>';
- }
- echo '</tr>';
- }
- echo '</table>';
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement