thx, now i understand that part!
Question 2:
My page with the form is on this page: 'gbookform.html'
My page with the form action: 'post.php',
Page with the entries: guestbook.php
Pages saved separately: config.php & opendb.php
Where does these next codes go?
CodeA:
Code: Select all
<?php
// how many guestbook entries to show per page
$rowsPerPage = 25;
// by default we show first page
$pageNum = 1;
if(isset($_GET['page']))
{
$pageNum = $_GET['page'];
}
$offset = ($pageNum - 1) * $rowsPerPage;
// prepare the query string
$query = "SELECT id,
name,
comments,
DATE_FORMAT(entry_date, '%d.%m.%Y') ".
"FROM guestbook ".
"ORDER BY id DESC ".
"LIMIT $offset, $rowsPerPage";
// ... the rest of the code
?>
This above one I'm guessing on my guestbook.php page but I'm not sure at all. If so, where? Do I put it in the heading or the body?
CodeB:
Code: Select all
<?php
// .... previous code
$query = "SELECT COUNT(id) AS numrows FROM guestbook";
$result = mysql_query($query) or die('Error, query failed');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];
$maxPage = ceil($numrows/$rowsPerPage);
$nextLink = '';
if($maxPage > 1)
{
$self = $_SERVER['PHP_SELF'];
$nextLink = array();
for($page = 1; $page <= $maxPage; $page++)
{
$nextLink[] = "<a href=\"$self?page=$page\">$page</a>";
}
$nextLink = "Go to page : " . implode(' » ', $nextLink);
}
include 'library/closedb.php';
?>
<table width="550" border="0" cellpadding="2" cellspacing="0">
<tr>
<td align="right" class="text">
<?=$nextLink;?>
</td>
</tr>
</table>
This above code includes the page 'closedb.php', I don't know what's suppose to be on that page because it's not really mentioned at all in the tutorial.
Thx for the upcoming replies!