Pagination
Tue, 04 Dec 2007 04:18:06
Pagination is where you have your query broke down into sections and then add "Next/Previous" buttons to your page. We're going to look at some PHP code which runs through the basics of this operation. If you'd like to learn PHP from scratch check out the 5 part introduction to PHP here: http://ryanpartington.com/tags/php/ (down by the bottom). Now lets get started...
I've just pasted some code I've recently used without comments. It's pretty self explanatory and basic but if you need any help, leave me a comment. First things first, lets look at our variables;
Now our MySQL query
Finally our hyperlinks;
Cheers
Ryan Partington
I've just pasted some code I've recently used without comments. It's pretty self explanatory and basic but if you need any help, leave me a comment. First things first, lets look at our variables;
- $page = $_GET['page'];
- IF(empty($page)){
- $page = 1;
- }
- $limit = $_GET['limit'];
- IF(empty($limit)){
- $limit = 25;
- }
- $limitvalue = $page * $limit - ($limit);
- $pageplus=$page; $pageplus++; $pageprev = $page; $pageprev--;
Now our MySQL query
- SELECT *
- FROM blg_article_art
- ORDER BY id_art DESC LIMIT $limit, $limitvalue
Finally our hyperlinks;
Cheers
Ryan Partington


