<?php
require_once('config.php');

$gbook_sql_1D_resource = mysql_query("SELECT * FROM `gbook_message` ORDER BY `datetime` DESC");
$gbook_display_2D_array = array();

while($gbook_processing_1D_array = mysql_fetch_array($gbook_sql_1D_resource))
{
	$gbook_processing_1D_array['datetime'] = date("Y-m-d H:i:s", $gbook_processing_1D_array['datetime']);
	$gbook_processing_1D_array['contents'] = nl2br($gbook_processing_1D_array['contents']);
	array_push($gbook_display_2D_array, $gbook_processing_1D_array);
}

mysql_close($db);
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>留言板範例</title>
</head>

<body>

<?php
for($i=0; $i<count($gbook_display_2D_array); $i++)
{
	?>
    名字：<?php echo $gbook_display_2D_array[$i]['username']?><br />
	時間：<?php echo $gbook_display_2D_array[$i]['datetime']?><br />
    內容：<?php echo $gbook_display_2D_array[$i]['contents']?><br />
    ----<br />
    <?php
}
?>

<form action="save.php" method="post">
  你的大名：<input type="text" name="username" /><br />
  留言內容：<textarea name="contents" cols="24" rows="5"></textarea><br />
  <input type="submit" value="留言" />
</form>
</body>
</html>
