Ohh thank you
I have that part figured out now, but now i have a new problem:
Splitting the results up into pages.
here's the message i posted on the PHPBB forums for help. So far no one is willing, so seem to know alot
Maybe this will be easy for you?
MESSAGE:
Hello this is to the creators / Designer of PHPBB
I'm creating my own forum from scratch, PHP BB kind-of inspired me to do so.
Now it's almost setup, users can view a forum, post, (Not yet reply but soon), and view posts.
The problem is, it will just display ALL the posts, I want to find a way to display only 20 per page.
Please creators, you made PHPBB, this should be easy Sad I've been looking around for help forever, no one will even atempt to help...
I'm storing the posts in a MySQL DB, and am using PEAR DB as the DB program.
Here's the code:
Code:
Code:
<?php
//require / load files
require "DB.php";
//start DB
$db = DB::connect('mysql://Username:Password@localhost/DB Name');
if (DB::isError($db)) { die ("Can't connect: " . $db->getMessage()); }
//setup error handling
$db->setErrorHandling(PEAR_ERROR_DIE);
session_start();
function show_forum($id)
{ //start function
global $db;
if($_SESSION['logged_in'])
{
if($id)
{
if($id == 1)
{
echo '<div style="text-align:center;"><img src="images/logo.jpg" alt="Xenur Logo" /></div>
<br />';
$rows = $db->getAll("SELECT id, title, short_desc, user, posts FROM posts_general ORDER BY id DESC");
echo '<a href="post_general.php"><img src="images/new_post.jpg" alt="Post A New Thread." /></a>';
echo '<table border="1" cellspacing="5" cellpading="0"><tr><th>Subject</th><th>Started By</th><th>Replies</th></tr>';
foreach ($rows as $row)
{
$row[4]--;
echo "<tr><td><a href='viewpostgeneral.php?id=" . $row[0] . "'>" . $row[1] . "</a><hr width='100%' color='cyan' />" . $row[2] . "</td><td>" . $row[3] . "</td><td>" . $row[4] . "</td></tr>\n";
}
echo '</table>';
}
}
elseif($id != 1)
{
die ('Forum does not exist!');;
}
}
else {
echo 'No forum to show';
}
}
show_forum($id);
?>
Now, as you can see I'm using foreach() to retrieve the posts.
How can I limit the posts returned to 20, and then make a formula to display the NEXT 20 results? Mad
I hope that's clear enough
Your my last resort, PLEASE, i beg of you, PLEASE help me with this. Sad
END MESSAGE
Thank you so much for your help already
