Reply
Help with Forum Script
Old 11-06-2004, 04:35 PM Help with Forum Script
Junior Talker

Posts: 2
Hello, i've been trying to figure this out for awhile now. I've been trying to get answers on the PHP Freaks forum, my topic can be found here:
http://www.phpfreaks.com/forums/inde...howtopic=45854

Now, if anyone can give me ANY help, it would be GREATLY apreciated
lilmeanman is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 11-06-2004, 08:28 PM
vivekar's Avatar
Webmaster Talker

Posts: 539
What PHPBB does is it stores fields such as
Code:
 `post_id` 	
 `topic_id` 		
 `forum_id` 		
 `poster_id` 		
 `post_time` 		
 `poster_ip` 		
 `post_username` 	
 `enable_bbcode` 	
 `enable_html` 	
 `enable_smilies` 
 `enable_sig` 		
 `post_edit_time` 
 `post_edit_count`
note the fields `post_id`, `topic_id`, `post_time`
when you "ORDER BY" your message by time, the replies would be set.

Hope this helps.
__________________
| Submit URL at All the Websites Directory
| Get Certified in Web Design
vivekar is offline
Reply With Quote
View Public Profile Visit vivekar's homepage!
 
Old 11-09-2004, 04:14 PM
Junior Talker

Posts: 2
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
lilmeanman is offline
Reply With Quote
View Public Profile
 
Old 11-12-2004, 02:08 AM
vivekar's Avatar
Webmaster Talker

Posts: 539
SELECT * FROM `posts_general` LIMIT 0 , 20

You can use the SQL for limiting your posts.
like
**** LIMIT 0, 20
**** LIMIT 20, 20
**** LIMIT 40, 20
First,
you should get the page number of the script.
$pn = $_GET['pn'];
Then, you have to multiply the $pn with the number of results you need.
like $rslt = $pn * 20;

Use this in your SQL

SELECT * FROM `posts_general` LIMIT $rslt , 20

Hope this helps.

I am sorry for the delayed reply. I was busy at the work.
__________________
| Submit URL at All the Websites Directory
| Get Certified in Web Design
vivekar is offline
Reply With Quote
View Public Profile Visit vivekar's homepage!
 
Reply     « Reply to Help with Forum Script
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12295 seconds with 12 queries