Search code examples
phppagination

How set paging in PHP?


I have an 300 rows(data) each page contain 10 records I need first 10 pages then click next then display next 10 page here is my code:

<?php


$eu = ($start - 0);
$limit = 10;
$this1 = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;


if ($nume > $limit)
{
    echo'<div class="pagination right">';
    if ($back >= 0)
    {
        echo"<a href='$page_name?start=$back&o" . $_SESSION['clicked'] . "&p=$desc'>&laquo;</a>";
    }

    $i = 0;
    $l = 1;
    for ($i = 0; $i < $nume; $i = $i + $limit)
    {
        if ($i <> $eu)
        {
            echo"<a href='$page_name?start=$i&o=" . $_SESSION['clicked'] . "&p=$desc'>$l</a>";
        }
        else
        {
            echo "<a  class='active'>$l</a>";
        }
        $l = $l + 1;
    }

    if ($this1 < $nume)
    {
        echo "<a href='$page_name?start=$next&o=" . $_SESSION['clicked'] . "&p=$desc'>&raquo;</a>";
    }

    echo '</div>';
}
echo '</div></div>';

?>

Then I will get response like this http://app.ologie.us/app/admin/Screen.png

Can any one please guide to effective paging in PHP.


Solution

  • Here's a tutorial on basic pagination.

    http://www.phpfreaks.com/tutorial/basic-pagination