Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>Document</title>
  8. </head>
  9. <body>
  10. <?php
  11. $path = './randomdata.csv';
  12. if(isset($_GET['a'])) {
  13. $a = $_GET['a'];
  14. }
  15. else {
  16. $a = '';
  17. }
  18. switch($a){
  19. case 'pregled': pregled();break;
  20. default: ispis();
  21. }
  22. function ispis(){
  23. $slova=array();
  24. global $path;
  25. $sadrzaj = file($path);
  26. foreach($sadrzaj as $s){
  27. $redak = explode("|",$s);
  28. if(!in_array(substr($redak[4],0,1),$slova)){
  29. array_push($slova,substr($redak[4],0,1));
  30. }
  31. }
  32. unset($slova[0]);
  33. sort($slova);
  34. foreach($slova as $s){
  35. echo '<a href="?a=pregled&slovo='.$s.'">'.$s.'</a><br>';
  36. }
  37.  
  38.  
  39. }
  40. function pregled(){
  41. $slovo=$_GET['slovo'];
  42. global $path;
  43. $sadrzaj = file($path);
  44. echo '<table border=1>';
  45. foreach($sadrzaj as $s){
  46. echo '<tr>';
  47. $redak = explode("|",$s);
  48. if(substr($redak[4],0,1)==$slovo){
  49. echo '<td>'.$redak[0].'</td>';
  50. echo '<td>'.$redak[1].'</td>';
  51. echo '<td>'.$redak[2].'</td>';
  52. echo '<td>'.$redak[3].'</td>';
  53. echo '<td>'.$redak[4].'</td>';
  54. echo '<td>'.$redak[5].'</td>';
  55. }
  56. echo '</tr>';
  57. }
  58. echo '</table>';
  59. }
  60.  
  61. ?>
  62. </body>
  63. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement