Hi, i need help with limiting the number of posts that are shown on each page. I also want to have a next button to show the next post, but i have no clue how to do this, and i really need help with it. Here is the showtopic.php page that shows the posts from my forum:
<?php
require(dirname(__FILE__) . '/backend.php');
//check for required info from the query string
if (!$_GET[topic_id]) {
header("Location: forums.php");
exit;
}
//connect to server and select database
$conn = mysql_connect("$host", "$user", "$pass") or die(mysql_error());
mysql_select_db("$db",$conn) or die(mysql_error());
//verify the topic exists
$verify_topic = "select topic_title from wap_forum_topics where topic_id = $_GET[topic_id]";
$verify_topic_res = mysql_query($verify_topic, $conn) or die(mysql_error());
if (mysql_num_rows($verify_topic_res) < 1) {
//this topic does not exist
$display_block = <<<_WML_
You have selected an invalid topic. Please <a href="forums.php">try again</a>.
_WML_;
} else {
//get the topic title
$topic_title = stripslashes(mysql_result($verify_topic_res,0, 'topic_title'));
//gather the posts
$get_posts = "select post_id, post_text, date_format(post_create_time, '%b %e %Y at %r') as fmt_post_create_time, post_owner from wap_forum_posts where topic_id = $_GET[topic_id] order by post_create_time asc";
$get_posts_res = mysql_query($get_posts,$conn) or die(mysql_error());
//create the display string
$display_block = <<<_WML_
<b>$topic_title</b><br/>
_WML_;
while ($posts_info = mysql_fetch_array($get_posts_res)) {
$post_id = $posts_info['post_id'];
$post_text = nl2br(stripslashes($posts_info['post_text']));
$post_create_time = $posts_info['fmt_post_create_time'];
$post_owner = stripslashes($posts_info['post_owner']);
//add to display
$display_block .= <<<_WML_
By $post_owner<br/>
[$post_create_time]<br/>
$post_text<br/>
<a href="replytopost.php?post_id=$post_id">Reply</a><br/>
------<br/>
_WML_;
}
}
opentable();
print $openp;
print $display_block;
print $closep;
closetable();
?>