Jump to content


Photo

Creating guestbook


  • Please log in to reply
2 replies to this topic

#1 AdRock

AdRock
  • Members
  • PipPipPip
  • Advanced Member
  • 911 posts

Posted 03 July 2006 - 09:51 PM

Hello

I am thinking of creating a guestbook for a website which isn't a problem but I want to know how to set the number of messages per page.

Say I wanted to display 10 messages per page and had 50 messages to be displayed, how would I include a link somewhere to move to the next set of messages and to display the number of pages?

Any help would be appreciated
If your topic has been solved, please mark the topic as SOLVED.

This helps others from identifying which topics need help still

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 03 July 2006 - 10:08 PM


an example only ok.

<? session_start();

$db=mysql_connect("xxxx" , "xxx" , "xxx");
mysql_select_db("promotor",$db);

?>


<html>
<head>
<title>Send Message</title>
<body bgcolor="#A0C0F0">
<br><br><br><br><br>



<?



if(!isset($_GET['page'])){
    $page = 1;
} else {
    $page = $_GET['page'];
}

$max_results = 1;


$from = (($page * $max_results) - $max_results);

$query="select * from xxxx where id='$id' LIMIT $from, $max_results";


$result=mysql_query($query);
while($record=mysql_fetch_assoc($result)){


echo"<table align='center' width='300'border='4' bordercolor='black'><td align='left'><b>Members Id:<font color='red'><br>".$record["sent_id"]."</font><br> User Name: <font color='red'><br>".$record["members_name"]."</font><br>
Sent Time: <font color='red'><br>".$record["time"]."</font> <br> Sent Date <font color='red'><br>".$record["date"]."</font> </b></td><td align='center' valign='top'><b>Members Message <font color='red'>$page</font><b>
<br><br><b><div align='left'><textarea col='7' rows='7'style='color: white; background-color: #A0C0F0'>".$record["message"]."</textarea></td></b></div><table>";





echo "<table align='center' width='300'border='4' bordercolor='black'><td align='center'><b>";


$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM member_messages where id='$id'"),0);


$total_pages = ceil($total_results / $max_results);


echo "<center><b>Select A Message!</b><br>";


if($page > 1){
    $prev = ($page - 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"></a>";
}

for($i = 1; $i <= $total_pages; $i++){
    if(($page) == $i){
        echo "$i ";
        } else {
            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
    }
}


if($page < $total_pages){
    $next = ($page + 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\"></a>";

}


echo "</center>";
echo'</td></table>';

echo "<table align='center' width='300'border='4' bordercolor='black'><td align='center'><b>Send A Reply    <font color='red'><a href='reply_message.php?&id=".$record['sent_id']."'>Reply</a></b></font>
<font color='red'><a href='delete_message.php?&cmd=delete&time=".$record['time']."&id=".$record['sent_id']."'>Delete</a></b></font>
</td></table><br>";
}

?>
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 Birdman203

Birdman203
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 03 July 2006 - 10:18 PM

I did this here look through it and learn!

<?php
require 'required.inc.php';


$news = $config[news];
$page = $_REQUEST['page'];
$mul2 = bcmul($page, $news);
$mul = bcsub($mul2, $news);
if (isset($page)) {
	$result = mysql_db_query("typekill_$config[short]", "select * from cp_ftopics where cat_id = '$config[news_cat]' order by id desc limit $mul, $config[news]");
	$smarty->assign("isset", "1");
} else {
	$result = mysql_db_query("typekill_$config[short]", "select * from cp_ftopics where cat_id = '$config[news_cat]' order by id desc limit 0, $config[news]") or die(mysql_error());
	$smarty->assign("isset", "0");
}
$count = mysql_num_rows($result);
if ($count > $mul) {
	if (isset($page)) {
		$nextp = $page + 1;
	} else {
		$nextp = $page + 2;
	}
	$smarty->assign("nextp", $nextp);
}
if ($count < $mul) {
	$backp = $page - 1;
	$smarty->assign("backp", $backp);
}
?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users