I have designed a guestbook using a MySQL database (where the entires are stored). I then display them in a table ordering them by date so that the lastest shows up at the top. Now, how can I make it so that instead of having 100 guestbook entries show up on one page, I can have like 10 per page and links to next and previous page? I've read about using split() for text data, but since this is a database and I'm using a table, I'm not quite sure how I would get it to work. Thanks!

Brian

    Take a look at the LIMIT clause on the select, the syntax is roughly:

    select * from table limit <offset>[,<limit>]

    So all you gotta do is pass the offset as a variable to each page =)

      Since I am doing an ORDER BY and basically displaying the rows from bottom to top, would that mess up the order?

      And how does one go about continuing on reading from the database on the next dynamic page without it wanting to start from the beginning of the table again? I almost understand how I can do this, but those are the few points that I don't quite know how to get around. Thanks for your help.

        Just make $offset a dynamic variable. For example, $offset would be 0 (zero) for the very first page. Then, if you have a $limit = 5, then $offset would be 5 for the following page and so on.

        There is an article about the next and previous links on the article section.

          Write a Reply...