Creating forum in PHP... get posts in pages?

  • Thread starter Thread starter Cameron V
  • Start date Start date
C

Cameron V

Guest
I'm programming my own forum in PHP. I have a MySQL database containing the fields forum_boards, forum_topics, and forum_posts. Say I have a page like:
index.php?topic=1
It would display the topic that has an ID of 1. It would also display all the posts that match the topic ID. Pretty simple stuff thus far.
But I would also like to add another functionality. I want pages--that is, only ten posts per page.
index.php?topic=1?page=1
index.php?topic=1?page=2
So the first page would display the first ten posts, and the second would display the next ten posts. Just a little shaky on how to do this. Some help would be appreciated.
 
yep thats right , may as well get 2 points for saying something tho , the person above gets the best answer and thumbs up.
 
This is a simple pagination scheme. All you got to do is add to your query the following:

limit 0,10

where

0 = the current page (like arrays, start at 0)
10 = the number of records that you want to display

At your PHP script you will need to control the pages, but, basically is calculating the number of pages that you will have at the full query and creating the pages where each page will call the query with the limit clause.
 
Back
Top