· 7 years ago · Oct 15, 2018, 11:36 AM
1<!doctype html>
2<html>
3<head>
4<meta charset="UTF-8">
5<!-- TemplateBeginEditable name="doctitle" -->
6<title>Unbenanntes Dokument</title>
7<!-- TemplateEndEditable -->
8<!-- TemplateBeginEditable name="head" -->
9<!-- TemplateEndEditable -->
10</head>
11
12<body>
13 <h1>Beiträge</h1>
14
15 <?php
16 require_once ('konfiguration.php'); # Konfiguration noch zu erstellen, sich mit dem Server verbinden.
17 $db_link = mysqli_connect (
18 "localhost",
19 "root",
20 "password"
21 );
22 $sql = "
23 IF NOT EXISTS CREATE TABLE `Beiträge` (
24 `id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
25 `Titel` VARCHAR( 150 ) NOT NULL ,
26 `Beschreibung` VARCHAR( 150 ) NULL ,
27 `Text` longtext NOT NULL ,
28 `Autor` VARCHAR( 150 ) NULL ,
29 `Datum` INT( 5 ) NOT NULL
30 ) ENGINE = MYISAM ;
31 ";
32
33 $db_erg = mysqli_query( $db_link, $sql );
34 if ( ! $db_erg )
35 {
36 die('Ungültige Abfrage: ' . mysqli_error());
37 }
38
39 echo '<table border="1">';
40 while ($zeile = mysqli_fetch_array( $db_erg, MYSQL_ASSOC))
41 {
42 echo "<tr>";
43 echo "<td>". $zeile['id'] . "</td>";
44 echo "<td>". $zeile['Titel'] . "</td>";
45 echo "<td>". $zeile['Beschreibung'] . "</td>";
46 echo "<td>". $zeile['Autor'] . "</td>";
47 echo "<td>". $zeile['Datum'] . "</td>";
48 echo "</tr>";
49 }
50 echo "</table>";
51
52 mysqli_free_result( $db_erg );
53 ?>
54</body>
55</html>