SQLITE3 - Paging, Refresh, Alphabetische Reihenfolge, Buchstabenauswahl verbauen

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • SQLITE3 - Paging, Refresh, Alphabetische Reihenfolge, Buchstabenauswahl verbauen

    Hallo zusammen,

    kann mir ein erfahrener PHP Coder die oben beschriebenen Funktionen verbauen? Ich wäre sehr sehr dankbar für Hilfe.
    Das Script sieht folgendermaßen aus:
    Spoiler anzeigen

    PHP-Quellcode

    1. <?php
    2. echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n";
    3. echo " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
    4. echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
    5. echo "<head>\n";
    6. echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\n";
    7. echo "<title>Scripte</title>\n";
    8. echo "<link href=\"css/styles.css\" rel=\"stylesheet\" type=\"text/css\" />\n";
    9. echo "</head>\n";
    10. echo "\n";
    11. echo "<body>\n";
    12. function refresh($content="") {
    13. echo "<META HTTP-EQUIV=Refresh CONTENT=\"".$content."\"; URL=\"scripts.php\">";
    14. }
    15. if(!($db=new SQLite3('sqlite/scripts.sqlite3', '0666')))
    16. {
    17. echo "<h2>Fehler</h2>";
    18. die();
    19. }
    20. echo "<table id=\"mytable\" cellspacing=\"0\" summary=\"Scriptauflistung\">\n";
    21. echo " <caption>\n";
    22. echo " <a href=\"scripts.php?action=add\">[Eintragen]</a>\n";
    23. echo " </caption>\n";
    24. echo " <tr>\n";
    25. echo " <th scope=\"col\" abbr=\"Name\" class=\"nobg\">Name</th>\n";
    26. echo " <th scope=\"col\" abbr=\"Version\">Version</th>\n";
    27. echo " <th scope=\"col\" abbr=\"Allinkwith\">Allinkwith</th>\n";
    28. echo " <th scope=\"col\" abbr=\"Boerse\">Boerse</th>\n";
    29. echo " <th scope=\"col\" abbr=\"MyGully\">MyGully</th>\n";
    30. echo " <th scope=\"col\" abbr=\"Leecher\">Leecher</th>\n";
    31. echo " <th scope=\"col\" abbr=\"Aktion\">Aktion</th>\n";
    32. echo " </tr>\n";
    33. $scriptname=$db->escapeString(@$_REQUEST['scriptname']);
    34. $scriptversion=$db->escapeString(@$_REQUEST['scriptversion']);
    35. $up_aiw=$db->escapeString(@$_REQUEST['up_aiw']);
    36. $up_boerse=$db->escapeString(@$_REQUEST['up_boerse']);
    37. $up_mygully=$db->escapeString(@$_REQUEST['up_mygully']);
    38. $up_leecher=$db->escapeString(@$_REQUEST['up_leecher']);
    39. $result=$db->query("SELECT id,scriptname,scriptversion,up_aiw,up_boerse,up_mygully,up_leecher FROM scripts ORDER BY scriptversion;");
    40. $i=0;
    41. while( $row=$result->fetchArray(SQLITE3_ASSOC) )
    42. {
    43. if($i>0)
    44. {
    45. }
    46. echo " <tr>\n";
    47. echo " <th scope=\"row\" abbr=\"Model\" class=\"spec\">".htmlspecialchars($row['scriptname'])."</th>\n";
    48. echo " <td class=\"version\">".htmlspecialchars($row['scriptversion'])."</td>\n";
    49. echo " <td><a href=\"".htmlspecialchars($row['up_aiw'])."\" target=\"_blank\"><img src=\"http://g.etfv.co/".htmlspecialchars($row['up_aiw'])."\" alt=\"n/a\" width=\"16\" height=\"16\" /></a></td>\n";
    50. echo " <td><a href=\"".htmlspecialchars($row['up_boerse'])."\" target=\"_blank\"><img src=\"http://g.etfv.co/".htmlspecialchars($row['up_boerse'])."\" alt=\"n/a\" width=\"16\" height=\"16\" /></a></td>\n";
    51. echo " <td><a href=\"".htmlspecialchars($row['up_mygully'])."\" target=\"_blank\"><img src=\"http://g.etfv.co/".htmlspecialchars($row['up_mygully'])."\" alt=\"n/a\" width=\"16\" height=\"16\" /></a></td>\n";
    52. echo " <td><a href=\"".htmlspecialchars($row['up_leecher'])."\" target=\"_blank\"><img src=\"http://g.etfv.co/".htmlspecialchars($row['up_leecher'])."\" alt=\"n/a\" width=\"16\" height=\"16\" /></a></td>\n";
    53. echo " <td><a href=\"scripts.php?action=del&amp;id=".$row['id']."\"><img src=\"img/delete.png\" alt=\"Del\" title=\"Löschen\" width=\"16\" height=\"16\" /></a> <a href=\"scripts.php?action=edit&amp;id=".$row['id']."\"><img src=\"img/edit.png\" alt=\"Edit\" title=\"Bearbeiten\" width=\"16\" height=\"16\" /></a></td>\n";
    54. echo " </tr>\n";
    55. $i++;
    56. }
    57. echo "</table>";
    58. //START: Eintrag einfügen
    59. if(@$_REQUEST['action']=="add") {
    60. if($scriptname!="") {
    61. $db->query("INSERT INTO scripts (scriptname,scriptversion,up_aiw,up_boerse,up_mygully,up_leecher) VALUES('$scriptname','$scriptversion','$up_aiw','$up_boerse','$up_mygully','$up_leecher')");
    62. }
    63. echo "<h3>Eintrag</h3>\n";
    64. echo "<form action=\"scripts.php\" method=\"get\">\n";
    65. echo "<input type=\"hidden\" name=\"action\" value=\"add\">\n";
    66. echo " <table id=\"mytable\" cellspacing=\"0\" summary=\"Scriptauflistung\">\n";
    67. echo " <tr>\n";
    68. echo " <th class=\"nobg\"><img src=\"img/textfield.png\" alt=\"n/a\" width=\"16\" height=\"16\" /> Scriptname:</th>\n";
    69. echo " <th class=\"nobg\"><input type=\"text\" size=\"30\" name=\"scriptname\"></th>\n";
    70. echo " </tr>\n";
    71. echo " <tr>\n";
    72. echo " <th class=\"nobg\"><img src=\"img/textfield.png\" alt=\"n/a\" width=\"16\" height=\"16\" /> Version:</th>\n";
    73. echo " <th class=\"nobg\"><input type=\"text\" size=\"30\" name=\"scriptversion\"></th>\n";
    74. echo " </tr>\n";
    75. echo " <tr>\n";
    76. echo " <th class=\"nobg\"><img src=\"img/link.png\" alt=\"n/a\" width=\"16\" height=\"16\" /> AIW Link:</th>\n";
    77. echo " <th class=\"nobg\"><input type=\"text\" size=\"30\" name=\"up_aiw\"></th>\n";
    78. echo " </tr>\n";
    79. echo " <tr>\n";
    80. echo " <th class=\"nobg\"><img src=\"img/link.png\" alt=\"n/a\" width=\"16\" height=\"16\" /> BOERSE Link:</th>\n";
    81. echo " <th class=\"nobg\"><input type=\"text\" size=\"30\" name=\"up_boerse\"></th>\n";
    82. echo " </tr>\n";
    83. echo " <tr>\n";
    84. echo " <th class=\"nobg\"><img src=\"img/link.png\" alt=\"n/a\" width=\"16\" height=\"16\" /> MYGULLY Link:</th>\n";
    85. echo " <th class=\"nobg\"><input type=\"text\" size=\"30\" name=\"up_mygully\"></th>\n";
    86. echo " </tr>\n";
    87. echo " <tr>\n";
    88. echo " <th class=\"nobg\"><img src=\"img/link.png\" alt=\"n/a\" width=\"16\" height=\"16\" /> LEECHER Link:</th>\n";
    89. echo " <th class=\"nobg\"><input type=\"text\" size=\"30\" name=\"up_leecher\"></th>\n";
    90. echo " </tr>\n";
    91. echo " <tr>\n";
    92. echo " <th class=\"nobg\"></th>\n";
    93. echo " <th class=\"nobg\"><input type=\"submit\" border=\"0\" value=\"Eintragen\"></th>\n";
    94. echo " </tr>\n";
    95. echo " </table>\n";
    96. echo "</form>\n";
    97. }
    98. //START: Eintrag Speichern
    99. if(@$_REQUEST['action']=="save")
    100. {
    101. $db->query("UPDATE scripts
    102. SET scriptname = '$scriptname', scriptversion = '$scriptversion', up_aiw = '$up_aiw', up_boerse = '$up_boerse', up_mygully = '$up_mygully', up_leecher = '$up_leecher'
    103. WHERE id=".round($_REQUEST['id']));
    104. refresh("0");
    105. }
    106. //START: Eintrag löschen
    107. if(@$_REQUEST['action']=="del")
    108. {
    109. $result=$db->query("SELECT id,scriptname,scriptversion,up_aiw,up_boerse,up_mygully,up_leecher FROM scripts WHERE id=".round($_REQUEST['id']));
    110. $row=$result->fetchArray(SQLITE3_ASSOC);
    111. echo "<h3>Löschen</h3>\n";
    112. echo "<form action=\"scripts.php\" method=\"post\">\n";
    113. echo "<input type=\"hidden\" name=\"action\" value=\"delok\">\n";
    114. echo "<input type=\"hidden\" name=\"id\" value=\"".$row['id']."\">\n";
    115. echo "<strong>".$row['scriptname']."</strong> wirklich löschen?<br /><input type=\"submit\" border=\"0\" value=\"Ja, löschen!\">";
    116. echo "</form>\n";
    117. }
    118. //START: Eintrag löschen OK
    119. if(@$_REQUEST['action']=="delok")
    120. {
    121. $db->query("DELETE FROM scripts WHERE id=".round($_REQUEST['id']));
    122. echo "<h3>Erolgreich gelösch</h3>\n";
    123. refresh("1");
    124. }
    125. //START: Eintrag editieren
    126. if(@$_REQUEST['action']=="edit")
    127. {
    128. $result=$db->query("SELECT id,scriptname,scriptversion,up_aiw,up_boerse,up_mygully,up_leecher FROM scripts WHERE id=".round($_REQUEST['id']));
    129. $row=$result->fetchArray(SQLITE3_ASSOC);
    130. echo "<h3>Bearbeiten</h3>\n";
    131. echo "<form action=\"scripts.php\" method=\"post\">\n";
    132. echo "<input type=\"hidden\" name=\"action\" value=\"save\">\n";
    133. echo "<input type=\"hidden\" name=\"id\" value=\"".$row['id']."\">\n";
    134. echo " <table id=\"mytable\" cellspacing=\"0\" summary=\"Scriptauflistung\">\n";
    135. echo " <tr>\n";
    136. echo " <th class=\"nobg\"><img src=\"img/textfield.png\" alt=\"n/a\" width=\"16\" height=\"16\" /> Scriptname:</th>\n";
    137. echo " <th class=\"nobg\"><input type=\"text\" size=\"30\" name=\"scriptname\" value=\"".$row['scriptname']."\"></th>\n";
    138. echo " </tr>\n";
    139. echo " <tr>\n";
    140. echo " <th class=\"nobg\"><img src=\"img/textfield.png\" alt=\"n/a\" width=\"16\" height=\"16\" /> Version:</th>\n";
    141. echo " <th class=\"nobg\"><input type=\"text\" size=\"30\" name=\"scriptversion\" value=\"".$row['scriptversion']."\"></th>\n";
    142. echo " </tr>\n";
    143. echo " <tr>\n";
    144. echo " <th class=\"nobg\"><img src=\"img/link.png\" alt=\"n/a\" width=\"16\" height=\"16\" /> AIW Link:</th>\n";
    145. echo " <th class=\"nobg\"><input type=\"text\" size=\"30\" name=\"up_aiw\" value=\"".$row['up_aiw']."\"></th>\n";
    146. echo " </tr>\n";
    147. echo " <tr>\n";
    148. echo " <th class=\"nobg\"><img src=\"img/link.png\" alt=\"n/a\" width=\"16\" height=\"16\" /> BOERSE Link:</th>\n";
    149. echo " <th class=\"nobg\"><input type=\"text\" size=\"30\" name=\"up_boerse\" value=\"".$row['up_boerse']."\"></th>\n";
    150. echo " </tr>\n";
    151. echo " <tr>\n";
    152. echo " <th class=\"nobg\"><img src=\"img/link.png\" alt=\"n/a\" width=\"16\" height=\"16\" /> MYGULLY Link:</th>\n";
    153. echo " <th class=\"nobg\"><input type=\"text\" size=\"30\" name=\"up_mygully\" value=\"".$row['up_mygully']."\"></th>\n";
    154. echo " </tr>\n";
    155. echo " <tr>\n";
    156. echo " <th class=\"nobg\"><img src=\"img/link.png\" alt=\"n/a\" width=\"16\" height=\"16\" /> LEECHER Link:</th>\n";
    157. echo " <th class=\"nobg\"><input type=\"text\" size=\"30\" name=\"up_leecher\" value=\"".$row['up_leecher']."\"></th>\n";
    158. echo " </tr>\n";
    159. echo " <tr>\n";
    160. echo " <th class=\"nobg\"></th>\n";
    161. echo " <th class=\"nobg\"><input type=\"submit\" border=\"0\" value=\"Bearbeiten\"></th>\n";
    162. echo " </tr>\n";
    163. echo " </table>\n";
    164. echo "</form>\n";
    165. }
    166. // Schließen
    167. $db->close();
    168. echo "<p><a href=\"index.php\">Startseite</a></p>\n";
    169. echo "</body>\n";
    170. echo "</html>\n";
    171. echo "\n";
    172. echo "</body>\n";
    173. echo "</html>\n";
    174. ?>
    Alles anzeigen


    Refresh:
    [php]if(@$_REQUEST['action']=="add") {[/php]
    Nach dem Eintragen soll ein Refresh erfolgen und somit auf Hauptseite wieder landen.
    Wenn ich das Refresh einbaue, dann fügt er durchgehen Einträge hinzu, dass soll nicht passieren.
    Nach "einem" Eintrag, soll der Refresh erfolgen.

    Paging:
    Eine Paging-Funktion, womit man beispielsweise nur 10 Einträge anzeigt und mit
    << < [1] [2] ......
    Zu vorherigen oder nächsten Einträge springen kann

    Buchstabenauswahl:
    Eine Auswahl der Buchstaben wäre ebenfalls super
    [#] [A] ....
    Somit nur Einträge mit den jeweiligen Buchstabe angezeigt werden

    Alphabetische Reihenfolge
    Eine Alphabetische Reihenfolge für die Einträge wäre auch super