Repository navigation
Expand file tree
/
Copy pathcreate.php
More file actions
67 lines (58 loc) · 1.98 KB
/
Copy pathcreate.php
File metadata and controls
67 lines (58 loc) · 1.98 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
// Datenbank erstellen oder öffnen
$db = new SQLite3('tournament.db');
// Verbindung checken
if (!$db) {
die("Failed to connect to SQLite: " . $db->lastErrorMsg());
}
// 1. spiele tabelle anlegen
$db->exec("CREATE TABLE IF NOT EXISTS spiele (
id INTEGER PRIMARY KEY,
gruppenphase VARCHAR(50),
ergebnis VARCHAR(50)
)");
// 2. platzierungstabelle anlegen
$db->exec("CREATE TABLE IF NOT EXISTS platzierung (
platz VARCHAR(10),
spieler VARCHAR(50),
spiele VARCHAR(50),
punkte VARCHAR(10)
)");
// Insert sample data into 'spiele' table
$db->exec("INSERT INTO spiele (id, gruppenphase, ergebnis) VALUES
(1, 'Gruppenphase A', '2-1'),
(2, 'Gruppenphase A', '1-1'),
(3, 'Gruppenphase B', '3-0'),
(4, 'Gruppenphase B', '0-2'),
(5, 'Gruppenphase C', '1-0'),
(6, 'Gruppenphase C', '2-2'),
(7, 'Gruppenphase D', '0-0'),
(8, 'Gruppenphase D', '4-1'),
(9, 'Gruppenphase E', '3-3'),
(10, 'Gruppenphase E', '2-1'),
(11, 'Gruppenphase F', '1-4')
");
// Insert sample data into 'platzierung' table
$db->exec("INSERT INTO platzierung (platz, spieler, spiele, punkte) VALUES
('1', 'Mario', '1', '10'),
('2', 'Luigi', '2', '8'),
('3', 'Peach', '3', '6'),
('4', 'Toad', '4', '5'),
('5', 'Bowser', '5', '3')
");
// Fetch and display data from 'spiele' table
echo "<h3>Spiele Table</h3>";
$results = $db->query("SELECT * FROM spiele");
while ($row = $results->fetchArray(SQLITE3_ASSOC)) {
echo "ID: {$row['id']} | Gruppenphase: {$row['gruppenphase']} | Ergebnis: {$row['ergebnis']}<br>";
}
echo "<hr>";
// Fetch and display data from 'platzierung' table
echo "<h3>Platzierung Table</h3>";
$results = $db->query("SELECT * FROM platzierung");
while ($row = $results->fetchArray(SQLITE3_ASSOC)) {
echo "Platz: {$row['platz']} | Spieler: {$row['spieler']} | Spiele: {$row['spiele']} | Punkte: {$row['punkte']}<br>";
}
// Close the database connection
$db->close();
?>