PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sun Nov 23, 2014 11:53 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: [help]Make pages for cms
PostPosted: Sat Oct 08, 2011 2:51 pm 
Offline
Forum Newbie

Joined: Mon Sep 19, 2011 4:59 pm
Posts: 1
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 ?


Top
 Profile  
 
PostPosted: Tue Oct 11, 2011 5:54 pm 
Offline
Forum Contributor

Joined: Tue Feb 16, 2010 6:39 pm
Posts: 254
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:

Code:
...LIMIT 10, 10


To get that you would use

Code:
<?php
$page 
= $_GET['page'];
$results = $_GET['results_per_page'];
$limit = 'LIMIT '.(($page - 1) * $results) . ', '.$results;
?>


Hope this helps.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group