ziyaretci-defteri.php5
<?php include 'includes/header.php'; ?>
<?php
function formatdate($timeformat,$timestamp) {
global $timezoneoffset;
$summertime = date("I")*3600;
$timestamp+=3600*intval($timezoneoffset)+$summertime;
return gmdate($timeformat, $timestamp);
}
$db_host = "dbhost";
$db_username = "uname";
$db_pass = "pass";
$db_name = "dbname";
$db = mysqli_connect("$db_host","$db_username","$db_pass", "$db_name") or die ("could not connect to mysql");
mysqli_set_charset($db, 'utf-8');
$result = mysqli_query($db, 'SELECT authorname, message, posttime, visible FROM bgb2_posts WHERE visible = 1 ORDER BY posttime DESC');
while ($row = mysqli_fetch_array($result))
{
$comments[] = array('author' => $row['authorname'], 'message' => $row['message'], 'time' => $row['posttime']);
}
$posttime = formatdate($timeformat, $comments['time']);
?>
<div id="title"><a href="tr.php">Ana Sayfa</a> » Ziyaretçi Defteri</div>
<div id="content">
<?php foreach ($comments as $comment):
echo "<p class='textbold'>" . utf8_encode($comment['author']) . " - " . $posttime . "</p>";
echo "<p>" . utf8_encode($comment['message']) . "</p>";
endforeach;
?>
</div>
<?php include 'includes/footer.php'; ?>
header.php
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<?php include 'includes/functions.php'; ?>
<head>
<title><?php sitename(); ?> Fethiye - Turkey</title>
<meta http-equiv="content-type" content="application/xhtml+xml;charset=utf-8" />
<meta http-equiv="cache-control" content="max-age=300" />
<meta name="description" content="Melek Apart Hotel Fethiye - Turkey" />
<meta name="keywords" content="fethiye,çalış plajı,calis beach,ölüdeniz,fethiye apart,fethiye otel,fethiye hotel" />
<meta name="HandheldFriendly" content="True" />
<meta name='viewport' content='user-scalable=no, width=device-width' />
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="header">
<a href="index.php"><div id="logo"><img src="images/logo.png" /></div></a>
</div>
All files are saved with utf8 encoding in Notepad++.
By the way, I am also trying to display time but cannot get it working. It's in this format in the database: 1211375284