Advertisement
Guest User

Untitled

a guest
Oct 6th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. <html>
  2. <head>
  3. <link rel="stylesheet" href="main.css">
  4. <title>Trimborn</title>
  5. </head>
  6.  
  7. <body>
  8. <div>
  9. <h1>Verwaltung der Tabelle: "Stundenplan"</h1>
  10. </div>
  11. <div class="nav">
  12. <ul class="breadcrumb">
  13. <li><a href="index.php">home</a></li>
  14. <li><a href="stundenplan.php">Stundenplan</a></li>
  15. <ul>
  16. </div>
  17. <div class="content">
  18. <form action="stundenplan.php" method="post"/>
  19. <table>
  20. <tr>
  21. <td>StundenplanID:</td><td><input type ="number" name="StundenplanID" size="11" maxlength="11"</td>
  22. <td>Tag:</td><td><input type ="varchar" name="Tag" size="10" maxlength="10" </td>
  23. <td>Fach:</td><td><input type ="varchar" name="Fach" size="10" maxlength="30"</td>
  24. <td>LehrerID:</td><td><input type ="number" name="LehrerID" size="11" maxlength="11"</td>
  25. <td>Stunde:</td><td><input type ="number" name="Stunde" size="10" maxlength="10"</td>
  26. <td>Raum:</td><td><input type ="char" name="Raum" size="10" maxlength="4"</td>
  27. <td>Klasse:</td><td><input type ="varchar" name="Klasse" size="10" maxlength="6"</td>
  28. </tr>
  29. </table>
  30. <button name="senden" type="submit"> Eingabe absenden </button>
  31. </form>
  32. <table border="1">
  33. <tr>
  34. <th>StundenplanID</th><th>Tag</th><th>Fach</th><th>LehrerID</th><th>Stunde</th><th>Raum</th><th>Klasse</th>
  35. </tr>
  36. <?php
  37. $servername = "localhost";
  38. $username = "root";
  39. $password = "";
  40. $database = "LUSD";
  41.  
  42. // Create connection
  43. $conn = new mysqli($servername, $username, $password, $database);
  44. if(isset($_POST["StundenplanID"])){
  45. $StundenplanID = $_POST["StundenplanID"];
  46. $Tag = $_POST["Tag"];
  47. $Fach = $_POST["Fach"];
  48. $LehrerID = $_POST["LehrerID"];
  49. $Stunde = $_POST["Stunde"];
  50. $Raum = $_POST["Raum"];
  51. $Klasse = $_POST["Klasse"];
  52. echo ("$StundenplanID $Tag $Fach $LehrerID $Stunde $Raum $Klasse");
  53.  
  54. $sql = "INSERT INTO Stundenplan VALUES (\"".$StundenplanID."\", \"".$Tag."\", \"".$Fach."\", \"".$LehrerID."\", \"".$Stunde."\"
  55. , \"".$Raum."\", \"".$Klasse."\")";
  56. echo ($sql);
  57. $result = mysqli_query($conn, $sql);
  58. }
  59. if(isset($_POST['delete'])) {
  60. $sql = "DELETE FROM Stundenplan WHERE StundenplanID =" .$_POST['delete']. "";
  61. echo ($sql);
  62. $result = mysqli_query($conn, $sql);
  63. } else {
  64. echo "";
  65. }
  66. $result = mysqli_query($conn, "SELECT * FROM Stundenplan;");
  67. if (!$result) {
  68. die("Fehler: " . mysqli_error($conn));
  69. }
  70.  
  71. while ($row = mysqli_fetch_assoc($result)) {
  72. echo("<tr>");
  73. echo("<td>" . $row['StundenplanID'] . "</td>\n");
  74. echo("<td>" . $row['Tag'] . "</td>\n");
  75. echo("<td>" . $row['Fach'] . "</td>\n");
  76. echo("<td>" . $row['LehrerID'] . "</td>\n");
  77. echo("<td>" . $row['Stunde'] . "</td>\n");
  78. echo("<td>" . $row['Raum'] . "</td>\n");
  79. echo("<td>" . $row['Klasse'] . "</td>\n");
  80. echo("<td><form action=\"\" method=\"POST\"><button name='delete' type='submit' value='".$row['StundenplanID']."'>Delete</button></form></td>");
  81. echo("</tr>");
  82. }
  83.  
  84. $conn->close();
  85. ?>
  86. </div>
  87. </body>
  88. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement