mysql result for pagination
Posted
by
Reteras Remus
on Stack Overflow
See other posts from Stack Overflow
or by Reteras Remus
Published on 2012-07-06T15:08:58Z
Indexed on
2012/07/06
15:15 UTC
Read the original article
Hit count: 130
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!
© Stack Overflow or respective owner