Lol 🙂
Ok, here is modified script:
<? include("auto_disable.inc"); ?>
<html>
<head>
<?
if ($newsid == "") {
$sql="SELECT * FROM guestbook ORDER BY bookid DESC";
$result=mysql_query($sql);
$ncount=0;
echo "<font size=1> </font>";
while ($myrow=mysql_fetch_array($result)) {
if ($ncount<22)
{
$ncount=$ncount+1;
?>
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#666666" bordercolor="#999999">
<tr>
<td bgcolor="#000000" width="99%"> <font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#0099FF">
<a href=index.php?bookid=<? echo $myrow["bookid"]; ?>>
<font size=3 > <b>
<? echo $myrow["bookname"]; ?>
</b></font> </a> </font></a>
<BR>
</a>
</font>
<font color=#CCCCCC size=1> <? echo $myrow["bookat"]; ?> By <? echo $myrow["bookby"]; ?></font>
</td>
</tr>
</table>
<div align="left"> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">
</font>
<table width="100%" border="0" cellspacing="0" cellpadding="8">
<tr>
<td><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<? echo $myrow["bookbody"]; ?>
</font></font></td>
</tr>
</table>
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">
</font></div>
</font>
<div align="left">
<?
}
}
} else {
$sql="SELECT * FROM book WHERE bookid=$bookid";
$result=mysql_query($sql);
$myrow=mysql_fetch_array($result);
printf("<div align=left>");
printf("<font size=3 color=#FF9900><b>%s</b></font> <font color=white size=1><b>By %s</b></font> <font color=#CCCCCC size=1> %s <br><BR></font>", $myrow["bookname"], $myrow["bookby"], $myrow["bookat"]);
printf("<font size=2>%s</font>", $myrow["bookbody"]);
}
?>
<?
//pagination
// limit value for number of records to be shown per page
// query database to find total number of records to display
$limit = 10;
$query_count = "select * from guestbook ORDER BY bookid DESC";
$result_count = mysql_query($query_count);
$totalrows = mysql_num_rows($result_count);
if(empty($page))
$page = 1;
$limitvalue = $page * $limit - ($limit);
$query = "select * from guestbook ORDER BY bookid LIMIT $limitvalue, $limit DESC";
$result = mysql_query($query) or die("Error: " . mysql_error());
$count_result = mysql_num_rows($result);
// Display links at the top to indicate current page and number of pages displayed
$numofpages = ceil($totalrows / $limit);
echo"<br><p>There are <b>$totalrows</b> posts.";
$from=$limit*$page-$limit+1;
$to=$from + $count_result-1;
// start 123 next>> table
echo "<table align=\"center\" width=\"90%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr><td width=\"50%\" bgcolor=\"$bg_colour\" align=\"left\">";if($numofpages>1){<td width=\"50%\" bgcolor=\"\" align=\"right\"><b>Go to page:</b> ";}
// display previous link if page is not 1
if($page != 1){
$pageprev = $page - 1;
echo("<a href=\"$PHP_SELF?page=$pageprev\"><< PREV</a> ");
}
// display page nos if not 1
for($i = 1; $i <= $numofpages; $i++){
if($numofpages>1){
if($i == $page)
echo(" ".$i." ");
else
echo(" <a href=\"$PHP_SELF?page=$i\">$i</a> ");
}}
// display next page link if there is more than one
if(($totalrows - ($limit * $page)) > 0){
$pagenext = $page + 1;
echo("<a href=\"$PHP_SELF?page=$pagenext\">NEXT >></a>");
}
// end 123 next>> table
echo"</td></tr></table><br>";
?>
<hr><Br>
<center>Submit a Message</center><br><br>
<?
if ($submit)
{
if (!$bookname)
{
echo "Please put in a name for your book article.<br>\n";
?>
<?
} else {
if (!$bookby)
{
echo "Please enter a username for you to be known by.<br><br>\n";
?>
<?
} else {
if (!$bookbody)
{
echo "Please enter your book.<br><br>\n";
?>
<?
} else {
$bookbody=ereg_replace("\n","<br>",$bookbody);
$date=date("l F d, @h:iA");
$bookname=addslashes($bookname);
$bookby=addslashes($bookby);
$bookbody=addslashes($bookbody);
$sql="INSERT INTO guestbook (bookname,bookby,bookbody,bookat) VALUES ('$bookname','$bookby','$bookbody','$date')";
$result=mysql_query($sql);
$sql="SELECT * FROM guestbook ORDER by bookid DESC LIMIT 0,1";
$result=mysql_query($sql);
while ($myrow=mysql_fetch_array($result))
{
$last_bookid=$myrow["bookid"];
}
$sql="INSERT INTO `forum_topic` (`boardid` , `topic_name` , `topic_by` , `topic_body` , `topic_date` , `topic_type` , `lastpost` , `topic_special_id` , `special_id_type`) VALUES ( '9', '$bookname', 'Admin', '$bookbody', '$date', '0', '0','$last_bookid','3')";
$result=mysql_query($sql);
echo "Your Message Has Been Posted - Please don't Refresh this page or your Message will post again. Instead Click Guestbook again in the Left Menu</a>\n";
}}}}
else {
?>
<form method=post action=index.php?page=guestbook>
<p>Subject:
<input type=text name=bookname size="30">
<br>
Your Name:
<input type=text name=bookby value=name size="20">
<br>
</p>
<p>Your Message:<Br><textarea rows=15 cols=60 wrap=virtual name=bookbody></textarea>
<br>
<br>
<input type=submit name=submit value="Send Post"> </p>
</form>
<?
}
?>
</body>
</html>
I noticed that on your page, you have the 1 2 3 so on pages going to this url:
http://www.castlefm.net/index.php?page=guestbook&number=4
It can't do that. It has to be this:
http://www.castlefm.net/index.php?page=guestbook&page=4
You must of screwed around with the links or something because they don't seem to be working right. Use exactly what I gave you unless it's absolutely nesecary to change.
-Blake