Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="de">
  3. <head>
  4. <title>CSV-LOADER</title>
  5. </head>
  6. <body>
  7. <h1>CSV-LOADER</h1>
  8. </body>
  9. </html>
  10. <?php
  11. if(!file_exists("test.csv")){
  12. echo"<h1>Error! File 'test.csv' Not Found</h1>";
  13. exit;
  14. }
  15. $b = file('test.csv');
  16. $einträge = count($b);
  17.  
  18. echo '<form acion="?">';
  19.  
  20. //DROPDOWN ANZAHL
  21. If (isset($_GET["ANZAHL"])) {
  22. $anzahleinträge = $_GET["ANZAHL"];
  23. } else {
  24. $anzahleinträge = 1;
  25. }
  26.  
  27. echo '<select name="ANZAHL" onchange="this.form.submit()">';
  28. for ($i = 1; $i <= $einträge; $i++) {
  29. if ($i == $anzahleinträge) {
  30. echo '<option value=' . $i . ' selected="selected">' . $i . '</option>';
  31. continue;
  32. }
  33. echo '<option value=' . $i . '>' . $i . '</option>';
  34. }
  35. echo '</select>';
  36.  
  37. //DROPDOWN SEITE
  38. If (isset($_GET["SEITE"])) {
  39. $seitenzahl = $_GET["SEITE"];
  40. } else {
  41. $seitenzahl = 1;
  42. }
  43.  
  44. $seiten = ceil($einträge / $anzahleinträge);
  45.  
  46. echo '<style> ul#menu li { display:inline;} </style>';
  47. echo '<ul id=menu>';
  48. for ($i = 1; $i <= $seiten; $i++) {
  49. if ($i == $seitenzahl) {
  50. echo '<li><input style="color:red" type="submit" name="SEITE" value="'.$i.'"></li>';
  51. continue;
  52. }
  53. echo '<li><input type="submit" name="SEITE" value="'.$i.'"></li>';
  54. }
  55. echo '</ul>';
  56. echo '</form>';
  57.  
  58.  
  59. //NUMMERN
  60. $totalmin = ($anzahleinträge * ($seitenzahl - 1)) + 1;
  61. $totalmax = $anzahleinträge * $seitenzahl;
  62.  
  63. //CSV AUSGABE
  64. $zähler = 0;
  65. $file_handle = fopen("test.csv", 'r');
  66. echo "<table border='1'>";
  67. while (($line = fgets($file_handle)) !== false) {
  68. $zähler++;
  69. if ($zähler > $totalmax or $zähler < $totalmin) {
  70. continue;
  71. }
  72. echo "<tr>";
  73. echo "<td>" . $line . "<br>" . "</td>";
  74. echo "<td>" . '<a style="color:red" href="?DEL=' . $zähler . '">' . $zähler . '</a></td>';
  75. echo "</tr>";
  76. }
  77. echo "</table>";
  78. fclose($file_handle);
  79. echo "By Steffan Wolter";
  80. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement