Hey, I edited the scripts and works perfect on my server now ๐
This is config.php :
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="triadpass"; // Mysql password
$db_name="guestbook"; // Database name
$tbl_name="guestbook"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect server ");
mysql_select_db("$db_name")or die("cannot select DB");
?>
And this is viewguestbook.php :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body><table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td><strong>View Guestbook | <a href="index.php?id=guestbook&page=guestbook">Sign Guestbook</a> </strong></td>
</tr>
</table>
<br>
<?php
include("config.php");
$rowsPerPage = 11;
$pageNum = 1;
if(isset($_GET['page']))
{
$pageNum = $_GET['page'];
}
$offset = ($pageNum - 1) * $rowsPerPage;
$sql="SELECT * FROM $tbl_name LIMIT $offset, $rowsPerPage";
$result=mysql_query($sql);
while($rows=mysql_fetch_array($result)){
?>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td><table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td>ID</td>
<td>:</td>
<td><? echo $rows['id']; ?></td>
</tr>
<tr>
<td width="117">Name</td>
<td width="14">:</td>
<td width="357"><? echo $rows['name']; ?></td>
</tr>
<tr>
<td>Email</td>
<td>:</td>
<td><? echo $rows['email']; ?></td>
</tr>
<tr>
<td valign="top">Comment</td>
<td valign="top">:</td>
<td><? echo $rows['comment']; ?></td>
</tr>
<tr>
<td valign="top">Date/Time </td>
<td valign="top">:</td>
<td><? echo $rows['datetime']; ?></td>
</tr>
</table></td>
</tr>
</table>
<BR>
<?
}
$query = "SELECT COUNT(name) AS numrows FROM $tbl_name";
$result = mysql_query($query) or die('Error, query failed');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];
$maxPage = ceil($numrows/$rowsPerPage);
$self = $_SERVER['PHP_SELF'];
if ($pageNum > 1)
{
$page = $pageNum - 1;
$prev = " <a href=\"$self?a=msg&c=out&page=$page\">[«]</a> ";
$first = " <a href=\"$self?a=msg&c=out&page=1\">[««]</a> ";
}
else
{
$prev = ' [«] '; // we're on page one, don't enable 'previous' link
$first = ' [««] '; // nor 'first page' link
}
if ($pageNum < $maxPage)
{
$page = $pageNum + 1;
$next = " <a href=\"$self?a=msg&c=out&page=$page\">[»]</a> ";
$last = " <a href=\"$self?a=msg&c=out&page=$maxPage\">[»»]</a> ";
}
else
{
$next = ' [»] '; // we're on the last page, don't enable 'next' link
$last = ' [»»] '; // nor 'last page' link
}
echo $first . $prev . " Page <strong>$pageNum</strong> of <strong>$maxPage</strong> " . $next . $last;
mysql_close(); //close database
?>
</body>
</html>
And the sql :
CREATE TABLE guestbook (
id int(4) NOT NULL auto_increment,
name varchar(65) NOT NULL default '',
email varchar(65) NOT NULL default '',
comment longtext NOT NULL,
datetime varchar(65) NOT NULL default '',
PRIMARY KEY (id)
) TYPE=MyISAM AUTO_INCREMENT=2 ;
I think that it will works now ๐