-
Notifications
You must be signed in to change notification settings - Fork 0
/
readNormTable.php
36 lines (31 loc) · 931 Bytes
/
readNormTable.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
// Datenbankverbindung herstellen
$dbhost = "";
$dbname = "";
$dbuser = "";
$dbpass = "";
$conn = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
if ($conn->connect_error) {
die("Verbindung zur Datenbank fehlgeschlagen: " . $conn->connect_error);
}
// Normtabelle aus Datenbank lesen und in normSE[][] einlesen
$query = "SELECT * FROM normSEhs ORDER BY kompetenzID";
$result = $conn->query($query);
if ($result->num_rows > 0) {
$rowIndex = 0;
while ($row = $result->fetch_assoc()) {
$normSE[$rowIndex][0] = $row["p1"];
$normSE[$rowIndex][1] = $row["p2"];
$normSE[$rowIndex][2] = $row["p3"];
$normSE[$rowIndex][3] = $row["p4"];
$normSE[$rowIndex][4] = $row["p5"];
$rowIndex++;
}
} else {
echo "Keine Daten in der Tabelle gefunden.";
}
// Datenbankverbindung schließen
$conn->close();
// normSE[][] als JSON-Ausgabe senden
echo json_encode($normSE);
?>