Simplificare numerotare in Script paginare
Scris: Lun Apr 27, 2015
Salut,
Am scriptul paginare de mai jos.
In prezent arata asa:
Am scriptul paginare de mai jos.
Cod: Selectaţi tot
<?
class Navigation
{
// $total_rows = total rows;
// $page = current page, if(empty($_GET['page'])) $page=1; else $page = $_GET['page'];
// $limit = number of rows per page, $limit != 0;
// $this_script = file name, it must finish with '?' or '&';
public function __construct()
{
//..
}
static function display($total_rows,$page,$limit,$this_script) // first page = 1
{
if(empty($page)) $page=1;
if($page > 1)
{
echo "<a class='LinkPage pagini' href='".$this_script."page=".($page-1)."'> « </a> ";
}
for($i=1;$i<=ceil($total_rows/$limit);$i++)
{
if($i == $page)
echo "<span class='page pagini'>".$i."</span>";
else
echo "<a href='".$this_script."page=".$i."' class='LinkPage pagini'>".$i."</a>";
}
if($page < ($total_rows/$limit))
{
echo " <a class='LinkPage pagini' href='".$this_script."page=".($page+1)."'> » </a> ";
}
}
}
?>
<< 1 2 3 4 5 6 7 >>
si doresc ca atunci cand paginile devin numeroase sa simplific cam asa:
<< 1 2 3 ... 6 7 >>
Ce trebuie sa modific?