The query is:
SELECT * FROM `news` ORDER BY `id` LIMIT ($curr_page * 5), ( ($curr_page * 5) + 5 )
Where $curr_page is a php variable which is getting a value from $_GET['page']
I want to make a pagination (5 news on each page), but I don’t know why the mysql is returning me extra values.
On the first page the result ok: $curr_page = 0
The query would be:
SELECT * FROM `news` ORDER BY `id` LIMIT 0, 5
But on the second page, the result from the query is adding extra news, 10 instead of 5.
The query on the second page:
SELECT * FROM `news` ORDER BY `id` LIMIT 5, 10
Whats wrong? Why the result has 10 values instead of 5?
Thank you!
look this example, the first parameter is the row to begin and the second is the number of result to display
in your case the second parameter is static and the first parameter
($curr_page * 5)