Reputation: 531
I'm building an infinite scroll for a photo gallery of a website. It starts with 6 photos loaded and should load 3 more photos every-time the user reach the end of the page.
So, me first mysql is:
SELECT * FROM tb_galeriaarte ORDER BY datafoto DESC LIMIT 0,6
When the user reach the end of the page, I'm using the following mysql command to add 3 more photos:
SELECT * FROM tb_galeriaarte ORDER BY datafoto DESC LIMIT 6,9
The problem is that it returns 4 records instead of 3 and I have no idea why it happens! Somebody can help me with that? what am I doing wrong?!
Upvotes: 0
Views: 409
Reputation: 9470
Just write
SELECT * FROM tb_galeriaarte ORDER BY datafoto DESC LIMIT 6,3
2nd digit of LIMIT points quantity but not top limit
Upvotes: 2
Reputation: 1269693
To add three more photos, the second limit
would be:
limit 6, 3
The arguments are offset and number of records. You are asking for 9 records starting on the 7th (the offset starts counting from zero).
Upvotes: 6