- set a variable that holds the number of results to display per page
- Run a basic query (such as SELECT * FROM table). Don't use LIMIT here
- Count the number of matches
- Figure out how many pages that number of matches will create by dividing the
number of matches by how many results per page you want (make sure to use ceil())
- Set a page variable so you know wha tpage you're on. If there's no page variable,
then set it to 1
- Create a start value. This will be the first record to pull out of your database with your
query. What this would be is the page you're on times the pagelimit. However keep in mind,
since you set your starting page to 1, you have to subtract 1 from the page you're on then
multiply.
- Create your links
Previous: if the page you are on is greater than 1, make previous link
Next:If the page you are on is less than the total number of pages, make next link
Dynamic Page links: Use a for loop where $i = 1. $i is less than or equal to the number
of pages. then auto increment. within your loop, if $i is equal to the page you're on,
then don't make that number a link, just post it. That way they know what page they're on.
If $i doesn't equal the page they're on, then make it a link
- Run the query over using LIMIT with the startnig number being your start variable, and the
number of results to pull to be your pagelimit variable.
http://www.phpbuilder.com/board/showthread.php?s=&threadid=10219415&highlight=display
I suggest you go to that post and check it out and see how it works. I wrote that a while back for someone and it's all commented so it's easy to understand, even for a noob.
Hope this helps.