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 ></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 ></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.