<!DOCTYPE html> <html lang="de"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Datenbankausgabe nur tabelle</title> <link rel="stylesheet" href="style.css"> </head> <body> <table> <tr> <th>Test_ID</th> <th>Date</th> <th>Theme</th> <th>Lernfeld</th> <th>Teacher</th> <th>T_ID</th> </tr> <?php require_once("db_connect.php"); $sql = 'SELECT * FROM Klausur'; foreach ($pdo->query($sql) as $row) { echo'<tr><td>'. $row['Test_ID'] .'</td><td>'. $row['Date'] .'</td><td>'. $row['Theme'] .'</td><td>'. $row['Subject'] .'</td><td>'. $row['Teach'] .'</td><td>'. $row['K_ID'] .'</td></tr>'; } echo "</table>"; ?> </body> </html>
<!DOCTYPE html> <html lang="de"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Datenbankausgabe</title> <link rel="stylesheet" href="style.css"> </head> <body> <table> <tr> <th>Klausur_ID</th> <th>Datum</th> <th>Thema</th> <th>Lernfeld</th> <th>Fachlehrer</th> <th>K_ID</th> </tr> <?php $neuKlausur = array(); $neuKlausur["Datum"] = $_GET["Datum"]; $neuKlausur["Thema"] = $_GET["Thema"]; $neuKlausur["Lernfeld"] = $_GET["Lernfeld"]; $neuKlausur["Fachlehrer"] = $_GET["Fachlehrer"]; $neuKlausur["K_ID"] = $_GET["K_ID"]; require_once("db_verbindung.php"); $statement = $pdo->prepare("INSERT INTO Klausur (Klausur_ID, Datum, Thema, Lernfeld, Fachlehrer, K_ID) VALUES (NULL, :Datum, :Thema, :Lernfeld, :Fachlehrer, :K_ID)"); $statement->execute($neuKlausur); $sql = 'SELECT * FROM Klausur'; foreach ($pdo->query($sql) as $row) { echo'<tr><td>'. $row['Klausur_ID'] .'</td><td>'. $row['Datum'] .'</td><td>'. $row['Thema'] .'</td><td>'. $row['Lernfeld'] .'</td><td>'. $row['Fachlehrer'] .'</td><td>'. $row['K_ID'] .'</td></tr>'; } echo "</table>"; ?> </body> </html>
Коментарии
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Datenbankausgabe nur tabelle</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<table>
<tr>
<th>Test_ID</th>
<th>Date</th>
<th>Theme</th>
<th>Lernfeld</th>
<th>Teacher</th>
<th>T_ID</th>
</tr>
<?php
require_once("db_connect.php");
$sql = 'SELECT * FROM Klausur';
foreach ($pdo->query($sql) as $row) {
echo'<tr><td>'. $row['Test_ID']
.'</td><td>'. $row['Date']
.'</td><td>'. $row['Theme']
.'</td><td>'. $row['Subject']
.'</td><td>'. $row['Teach']
.'</td><td>'. $row['K_ID']
.'</td></tr>';
}
echo "</table>";
?>
</body>
</html>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Datenbankausgabe</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<table>
<tr>
<th>Klausur_ID</th>
<th>Datum</th>
<th>Thema</th>
<th>Lernfeld</th>
<th>Fachlehrer</th>
<th>K_ID</th>
</tr>
<?php
$neuKlausur = array();
$neuKlausur["Datum"] = $_GET["Datum"];
$neuKlausur["Thema"] = $_GET["Thema"];
$neuKlausur["Lernfeld"] = $_GET["Lernfeld"];
$neuKlausur["Fachlehrer"] = $_GET["Fachlehrer"];
$neuKlausur["K_ID"] = $_GET["K_ID"];
require_once("db_verbindung.php");
$statement = $pdo->prepare("INSERT INTO Klausur (Klausur_ID, Datum, Thema, Lernfeld, Fachlehrer, K_ID)
VALUES (NULL, :Datum, :Thema, :Lernfeld, :Fachlehrer, :K_ID)");
$statement->execute($neuKlausur);
$sql = 'SELECT * FROM Klausur';
foreach ($pdo->query($sql) as $row) {
echo'<tr><td>'. $row['Klausur_ID']
.'</td><td>'. $row['Datum']
.'</td><td>'. $row['Thema']
.'</td><td>'. $row['Lernfeld']
.'</td><td>'. $row['Fachlehrer']
.'</td><td>'. $row['K_ID']
.'</td></tr>';
}
echo "</table>";
?>
</body>
</html>