<html>
<head>
<title>Mein Gästebuch</title>
</head>
<body>
<h2>Mein Gästebuch</h2>
<a href="#neuereintrag">Eintrag hinzufügen</a><br><br>
<?php
$DatabasePointer = mysql_connect("localhost", "eintrag", "test");
mysql_select_db("mydatabase", $DatabasePointer);
$ResultPointer = mysql_query("SELECT * FROM gaestebuch ORDER BY Erstellt DESC", $DatabasePointer);
?>
<table border="0">
<?php
for($i = 0; $i < mysql_num_rows($ResultPointer); $i++)
{
$gaestebuch = mysql_fetch_object($ResultPointer);
?>
<tr>
<td><b>#<?php echo$i+1; ?>: <?php echo $gaestebuch->Titel; ?></b></td>
</tr>
<tr>
<td><?php echo nl2br($gaestebuch->Eintrag); ?></td>
</tr>
<tr>
<td>Eintrag von <b><?php echo$gaestebuch->Name; ?></b> am <b><?php echo substr($gaestebuch->Erstellt, 8, 2); ?>.<?php echo substr($gaestebuch->Erstellt, 5, 2); ?>.<?php echo substr($gaestebuch->Erstellt, 0, 4); ?> <?php echo substr($gaestebuch->Erstellt, 10); ?></b></td>
</tr>
<tr>
<td><hr></td>
</tr>
<?php
}
?>
</table><br><br>
<h3><a name="neuereintrag">Neuer Eintrag:</a></h3>
<form action="eintrag-einfuegen.php" method="post">
<table border="0">
<tr>
<td><b>Name:</b></td>
<td><input name="Name" maxlength="50" type="text"></td>
</tr>
<tr>
<td><b>Titel des Eintrages:</b></td>
<td><input maxlength="40" name="Titel" type="text"></td>
</tr>
<tr>
<td><b>Eintrag:</b></td>
<td><textarea cols="30" name="Eintrag" rows="5"></textarea></td>
</tr>
<tr>
<td align="center" colspan="2">
<input name="Send" type="submit" value="Eintragen">
<input name="Reset" type="reset" value="Löschen">
</td>
</tr>
</table>
</form>
</body>
</html>