Grow your CSS skills. Land your dream job.

PHP paging problem!

  • # July 19, 2012 at 8:46 pm

    This is basically my paging system right now:

    < ?php
    $limit = mysql_escape_string($_GET);
    if (empty($limit)){
    $limit = "1";
    }
    $page = $limit * 10;
    $flim1 = $page / 10;
    $flim = $page - 10;
    /* So basically, the 'p' is the page number, and $flim is "from" and $limit is "to"
    so this is at the end of the query I use to get my posts, feed or whatever */
    ... LIMIT $flim, $page");
    ?>

    In my login, this would mean that if the page number is one, it would chose everything from 1 to 10, which is correct. But when I come to page number two, i get 20!

    Can you see something I’m doing wrong here?

    # July 20, 2012 at 3:48 pm

    What do you want to achieve? When I use the following:

    < ?php
    $limit = mysql_escape_string($_GET);
    if (empty($limit) ){
    $limit = "1";
    }
    $page = $limit * 10;
    $flim = $page - 10;
    echo $flim ."-". $page;
    ?>

    I get the following output:

    p=1

    0-10

    p=2

    10-20

    p=5

    40-50

    What do you think I should be getting?

    # July 20, 2012 at 4:04 pm

    @BenWalker – I should mark this as solved. I misunderstood the “LIMIT” in mysql, I thought it was FROM, TO, but it is FROM, AMOUNT – so I figured it out :)

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

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".