Pagination without MySQL

This is a discussion on "Pagination without MySQL" within the PHP Forum section. This forum, and the thread "Pagination without MySQL are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Dec 14th, 2006, 10:30
New Member
Join Date: Dec 2006
Location: Finland
Age: 19
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Pagination without MySQL

Hello everyone! I'm wondering if it's possible to make PHP pagination without using MySQL? I've read a lot of tutorials, but they give a PHP file with a MySQL script and I've no idea what to do with the file. Someone said I'll need to upload the images (I want to paginate) to a MySQL database, but the problem is - I don't know how to do that.

So, is there a way to paginate my pages without MySQL? Like in CuteNews? CuteNews don't require MySQL and they are paginated.

Thanks!
Reply With Quote

  #2 (permalink)  
Old Dec 14th, 2006, 20:53
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: Pagination without MySQL

If the content/layout of your pages is fixed enough for you to calculate as part of compiling the page whena page is 'full', then you can include form feed characters as part of your processing.
Reply With Quote
  #3 (permalink)  
Old Dec 18th, 2006, 15:01
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Pagination without MySQL

I don't understand what you want to do, exactly. "Paginate" can mean different things. But whatever you want to do can't be that hard if it doesn't involve a database. (I imagine the reason you see instructions on pagination involving mysql is that it is harder, not because it is easier.)

I'm guessing what you want to do is show page 1 and then generate a link to the next page. Off the top of my head, here's one way to do it: First page:
Code: Select all
<?php            
$page = (int) 1; //first page only
$countpages = 4;//first page only, use an appropriate method to count the total pages

$pageno = $page;
$page=($page + 1);
if ($pageno > 1)  
      {echo "<div class=\"fl\"> Page Number $pageno</div>";}
if ($pageno <= $countpages)
      {echo "<div class=\"fr\"><a href=\"./page$page.php?page=$page&countpages=$countpages\">To page $page &nbsp;&gt;</a>";
      }
?>
Subsequent pages:
Code: Select all
<?php    
if (is_integer($_GET['page'])) { $page=$_GET['page'];} //subsequent pages
if (is_integer($_GET['countpages'])) { $countpages=$_GET['countpages'];}; //subsequent pages
$pageno = $page;
$page=($page + 1);
if ($pageno > 1)  
      {echo "<div class=\"fl\"> Page Number $pageno</div>";}
if ($page <= $countpages)
      {echo "<div class=\"fr\"><a href=\"./page$page.php?page=$page&countpages=$countpages\">To page $page &nbsp;&gt;</a>";
      }
?>
I hope that helps. Obviously the classes and positioning for the Page Number and link must be customized. Also you'd need to put in the right number for the original $countpages, or else generate it. Your files would of course be named page1.php, page2.php, etc.
Reply With Quote
  #4 (permalink)  
Old Jan 21st, 2007, 23:06
Junior Member
Join Date: Jan 2006
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Pagination without MySQL

Pagination is generally talked about in relation to databases simply because that's when it's most useful - when the number of results returned is variable so you don't know in advance how many results there are and want to split content into manageable chunks.

But anyhow, the answer is yes - you can write some code like that above to paginate flat content or content held in files rather than a database.
Reply With Quote
Reply

Tags
php pagination

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need small help with pagination ofi PHP Forum 0 Feb 7th, 2007 11:44
RSS feed pagination deesto Web Page Design 0 Dec 24th, 2006 02:31
PHP pagination robertboyle PHP Forum 1 Jul 30th, 2006 18:08
help with pagination and html radio buttons AdRock PHP Forum 5 Jul 27th, 2006 12:10
Pagination with PHP and switch statement AdRock PHP Forum 6 Jul 23rd, 2006 08:30


All times are GMT. The time now is 21:37.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43