Treehouse: Grow your CSS skills. Land your dream job.

Number of pages?

  • # February 22, 2012 at 6:48 pm

    Usually on forum sites such as this one css-tricks. On the bottom it has page 1, 2, 3 etc. it aslo has the next page button and the previous button. My question is how would one do such a thing?

    # February 22, 2012 at 9:47 pm

    Whatever software you use to power your forum — the pagination is usually taken care of automatically, though you will have to define in the forum settings how many discussions a page will have maximum, and how many posts should a discussion have maximum, before it’s divided into pages.

    # February 23, 2012 at 3:37 pm

    IF you are using a “while ($row = mysql_fetch_assoc…” you can easily in the string you are refering to (the one where you pull out the information you list) change the limit according to say “page” from the URL.
    Something like this:

    $limit = $_GET;
    if (empty($limit)){
    $limit = 10;
    $string = mysql_query("SELECT * FROM forums LIMIT 0, $limit");
    while ($row = mysql_fetch_assoc($string)){

    This is how I do it. Then I add a link that’s somewhat like this below everything:

    ">Display more

    You can of course change the first limit as well to be -10 of what the second one is, making them into “pages”.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.