Tuesday, June 25, 2013

Simple PHP Pagination

Download this file
https://docs.google.com/file/d/0B-WSEGv0VCtJYXRRQkRIVlFpNEE/edit?usp=sharing

Make this as pagination.php and include to your php file

 <?php include("pagination.php");
            echo pagination(20, $page, 'mypage.php?page=', $count);
?>
In mypage.php you should use the sql query according to pagination
<?php
$query="select * from table "
if (isset($_GET['page'])) {
        $start = ($_GET['page'] - 1) * 20;
       $query.=" limit $start,20";
     

    } else {
$query.=" limit 20";
     
    }
$result=mysql_fetch_array(mysql_query($query));
?>

No comments:

Post a Comment