I’m sorry I’m weak for English. i echo 2 row in each page . how echo next 2 row
JavaScript
x
SELECT *
FROM `mzmx_post`
JOIN mzmx_post_category
WHERE mzmx_post.id = mzmx_post_category.post_id AND zmx_post_category.category_id = 5
ORDER BY id DESC
LIMIT 2
Advertisement
Answer
You can use the two-arguments form of LIMIT
to offset the result by a given number of rows, like:
JavaScript
SELECT *
FROM `mzmx_post`
JOIN mzmx_post_category ON mzmx_post.id = mzmx_post_category.post_id
WHERE mzmx_post_category.category_id = 5
ORDER BY id DESC
LIMIT 2, 2 -- fetch records 3 and 4
This gives you the second page. If you want the third page, then:
JavaScript
LIMIT 4, 2
And so on.
Note that I modified your query so the joining condition between the tables is placed in the ON
clause of the join rather than in the WHERE
clause.