Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

DBMS 

SQL - Limits not working - limits doubling.

So I have been experimenting with a SQL paginator. My SQL query is this:

[img]http://screenshu.com/static/uploads/temporary/jy/0p/ce/tiqavq.jpg[/img]

On the first page it displays 10 results, on the second page it displays 20 results, on the third page it displays 30 results. The results are not the same but new results that range.

Page 1:

[img]http://screenshu.com/static/uploads/temporary/wu/53/on/ajjlk7.jpg[/img]

Page 2:

[img]http://screenshu.com/static/uploads/temporary/42/x3/2n/luv0zd.jpg[/img]

And so on.

Why is this happening?
In your while statement you have

Code
$limit = $limit + 10

So surely, every time you're clicking next, that is just adding 10 to the limit range.
aint my sig design skills sick?
Hi,

I think you got the usage of LIMIT wrong.

Code
Select * from countries ORDER BY country LIMIT 10,20 ;

The above statement will basically return you the 20 results after the 10th element. Please try the following code

Code
'Select * from countries ORDER BY country LIMIT '.($limit - 10) .',10'

in the $db->query() statement.

I'm no expert in programming and using this platform to learn myself so I apologize in advance if this doesn't help you. Hope this helps though.

Good luck;
Leather.