<?php
function paginate($page, $path, $tr, $limit, $condition, $tab)
{
if ($page > 1)
{
$first = 1;
echo ("<a href=\"$path?$condition&page=$first$tab\">First</a> ");
}
if ($page > 1)
{
$pageprev = $page - 1;
echo ("<a href=\"$path?$condition&page=$pageprev$tab\">PREV</a> ");
}
$numofpages = ceil($tr / $limit);
if ($numofpages >= 10)
{
if ($page <= $numofpages - 10)
{
$tpages = $page + 10;
$start = $page;
}
else
{
$tpages = $numofpages;
$start = $numofpages - 9;
}
}
else
{
$start = 1;
$tpages = $numofpages;
}
for ($i = $start; $i <= $tpages; $i++)
{
if ($page == $i)
{
if (isset($_GET['page']) && $tr > $limit) echo ($i . " ");
}
else echo ("<a href=\"$path?$condition&page=$i$tab\">$i</a> ");
}
if ($page < $numofpages)
{
$pagenext = ($page + 1);
echo ("<a href=\"$path?$condition&page=$pagenext$tab\">NEXT</a>");
}
if ($page != $numofpages && $page != 0)
{
$last = $numofpages;
if ($tr >= 1) echo (" <a href=\"$path?$condition&page=$last$tab\">Last</a>");
}
} ?>
0 comments:
Post a Comment