Hi all
I'm working on a cms
lets assume that in index page we have 3 articles
I want to make page for the other article
for example article 4 to 6 be in page 2 , article 7 to 9 be in page 3 and ...
i want to pages be added when I add new articles
what should id do ?
[help]Make pages for cms
Moderator: General Moderators
Re: [help]Make pages for cms
You can use the LIMIT clause in your MySQL query to paginate your results from the database. Ideally you would grab a query variable from the url for page and results_per_page, for example, and use that to generate the LIMIT clause. So http://www.your-site.com?page=2&results_per_page=10 would generate a LIMIT clause like so:
To get that you would use
Hope this helps.
Code: Select all
...LIMIT 10, 10Code: Select all
<?php
$page = $_GET['page'];
$results = $_GET['results_per_page'];
$limit = 'LIMIT '.(($page - 1) * $results) . ', '.$results;
?>