-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path_initdb.php
More file actions
34 lines (29 loc) · 835 Bytes
/
Copy path_initdb.php
File metadata and controls
34 lines (29 loc) · 835 Bytes
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
<?php
require_once "settings.php";
$connection = new mysqli($sql_server, $sql_user, $sql_pw, $sql_db);
if (mysqli_connect_errno()) {
printf("Could not connect to MySQL databse: %s\n", mysqli_connect_error());
exit();
}
$query = "SELECT ID FROM feedback";
$result = mysqli_query($connection, $query);
if(empty($result)) {
$query = "CREATE TABLE IF NOT EXISTS feedback (
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(32),
datum DATE,
zeit TIME,
text TEXT,
PRIMARY KEY (id)
)";
if (mysqli_query($connection, $query)) {
echo "Tabelle wurde erfolgreich erstellt.";
}
else {
echo "Fehler: " . $query . "<br>" . mysqli_error($connection);
}
} else {
echo "Tabelle existiert bereits. Abbruch.";
}
mysqli_close($connection);
?>