$top = $page * 20 - 20; $bottom = $top + 19; #### $top = $page * 20; $bottom = $top + 19; #### $top = $page * 20 - 19; $bottom = $top + 19; # A clearer Alternative: $bottom = $page * 20; $top = $bottom - 19; #### $top = $pages * 20 + 1; $bottom = $top + 19;