So basically, this is how my paging query looks like at the moment:
$limit = mysql_escape_string($_GET['pagenumber']);
if (empty($limit)){
$limit = "1";
}
$page = $limit * 10;
$flim1 = $page / 10;
$flim = $page - 10;
At the end of my query, I have this:
... LIMIT $flim, $page
Which should be from 1, 10 if the pagenumber is 1 and 10, 20 if the page number is 2. It works on the first page perfectly, but when I get to the second, there were 20 results, although when I echoed $flim and $page, they were 10 and 20. I cannot understand why!
I've heard about some double-query for paging. If you know a simple way to do this that is kind of like this one, please post a link. Will my method work?
Please see specification of LIMIT
there is LIMIT offset,count
So in your situation it would be LIMIT $flim,10
Full code:
$page = mysql_escape_string($_GET['pagenumber']);
if (empty($limit)){
$page = "1";
}
$items_per_page=10;
$offset = ($page-1)*$_items_per_page;
Then LIMIT $offset,$items_per_page
Additionally you would need count for all items to not get above max page