Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
07-19-2014, 10:28 AM #1
- Join Date
- Jul 2014
- Thanked 0 Times in 0 Posts
Blog - Limit posts on page, next page
Hi everyone. I'm a bit stuck on limiting posts on a page for a blog, and then have next page(page numbers). See the simple script below.
Not ideal if I have 20 posts as all on one page.
Does anyone know how I can limit this to 10 on the page?, I would quite like to have some sort of next page links or page numbers after 10 posts?
Even better if someone knows a youTube video or some other good resource to help?
Don't knwo where to begin with this so any help most appriciated.
07-19-2014, 09:44 PM #2
Paging if very very easy with MySQL!
You just have to use the LIMIT keyword in you query.
So something as simple as this:Code:
$pageSize = 10; // or any other size $pageNumber = $_REQUEST("pageNumber"); // get page number from GET or POST if ( ! isset($pageNumber) ) $pageNumber = 1; $startLimit = ( $pageNumber - 1 ) * $pageSize; $sql = "SELECT ... FROM ... ORDER BY ... LIMIT $startLimit, $pageSize"; ....Be yourself. No one else is as qualified.