Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <link rel="stylesheet" href="main.css">
- <title>Trimborn</title>
- </head>
- <body>
- <div>
- <h1>Verwaltung der Tabelle: "Stundenplan"</h1>
- </div>
- <div class="nav">
- <ul class="breadcrumb">
- <li><a href="index.php">home</a></li>
- <li><a href="stundenplan.php">Stundenplan</a></li>
- <ul>
- </div>
- <div class="content">
- <form action="stundenplan.php" method="post"/>
- <table>
- <tr>
- <td>StundenplanID:</td><td><input type ="number" name="StundenplanID" size="11" maxlength="11"</td>
- <td>Tag:</td><td><input type ="varchar" name="Tag" size="10" maxlength="10" </td>
- <td>Fach:</td><td><input type ="varchar" name="Fach" size="10" maxlength="30"</td>
- <td>LehrerID:</td><td><input type ="number" name="LehrerID" size="11" maxlength="11"</td>
- <td>Stunde:</td><td><input type ="number" name="Stunde" size="10" maxlength="10"</td>
- <td>Raum:</td><td><input type ="char" name="Raum" size="10" maxlength="4"</td>
- <td>Klasse:</td><td><input type ="varchar" name="Klasse" size="10" maxlength="6"</td>
- </tr>
- </table>
- <button name="senden" type="submit"> Eingabe absenden </button>
- </form>
- <table border="1">
- <tr>
- <th>StundenplanID</th><th>Tag</th><th>Fach</th><th>LehrerID</th><th>Stunde</th><th>Raum</th><th>Klasse</th>
- </tr>
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $database = "LUSD";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $database);
- if(isset($_POST["StundenplanID"])){
- $StundenplanID = $_POST["StundenplanID"];
- $Tag = $_POST["Tag"];
- $Fach = $_POST["Fach"];
- $LehrerID = $_POST["LehrerID"];
- $Stunde = $_POST["Stunde"];
- $Raum = $_POST["Raum"];
- $Klasse = $_POST["Klasse"];
- echo ("$StundenplanID $Tag $Fach $LehrerID $Stunde $Raum $Klasse");
- $sql = "INSERT INTO Stundenplan VALUES (\"".$StundenplanID."\", \"".$Tag."\", \"".$Fach."\", \"".$LehrerID."\", \"".$Stunde."\"
- , \"".$Raum."\", \"".$Klasse."\")";
- echo ($sql);
- $result = mysqli_query($conn, $sql);
- }
- if(isset($_POST['delete'])) {
- $sql = "DELETE FROM Stundenplan WHERE StundenplanID =" .$_POST['delete']. "";
- echo ($sql);
- $result = mysqli_query($conn, $sql);
- } else {
- echo "";
- }
- $result = mysqli_query($conn, "SELECT * FROM Stundenplan;");
- if (!$result) {
- die("Fehler: " . mysqli_error($conn));
- }
- while ($row = mysqli_fetch_assoc($result)) {
- echo("<tr>");
- echo("<td>" . $row['StundenplanID'] . "</td>\n");
- echo("<td>" . $row['Tag'] . "</td>\n");
- echo("<td>" . $row['Fach'] . "</td>\n");
- echo("<td>" . $row['LehrerID'] . "</td>\n");
- echo("<td>" . $row['Stunde'] . "</td>\n");
- echo("<td>" . $row['Raum'] . "</td>\n");
- echo("<td>" . $row['Klasse'] . "</td>\n");
- echo("<td><form action=\"\" method=\"POST\"><button name='delete' type='submit' value='".$row['StundenplanID']."'>Delete</button></form></td>");
- echo("</tr>");
- }
- $conn->close();
- ?>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement