linguagem?
so vendo como está o teu codigo é que poderemos ajudar.
Mas podes ser mais explicito? Queres limitar/truncar o n.º de paginas a 6 e por um 'seguinte'? Ou fazer a paginação ('pag. 2 de 6')?
function getPageNo() {
$str="";
$str=$str."<table width='200' border='0'><tr>";
$str=$str."<td width='30%' align='left' valign='top'>";
if($this->getPage()>1) {
$str=$str."<a href='".$_SERVER['PHP_SELF']."?page=".($this->getPage()-1).$this->getParameter()."' class='".$this->getStyle()."'>Anterior</a> ";
}
for($i=1;$i<=$this->getNoOfPages();$i++) {
if($i==$this->getPage()) {
$str=$str."<span class='".$this->getActiveStyle()."'>".$i." </span>";
}
else {
$str=$str."<a href='".$_SERVER['PHP_SELF']."?page=".$i.$this->getParameter()."' class='".$this->getStyle()."'>".$i."</a> ";
}
}
if($this->getPage()<$this->getNoOfPages()) {
$str=$str."<a href='".$_SERVER['PHP_SELF']."?page=".($this->getPage()+1).$this->getParameter()."' class='".$this->getStyle()."'>Seguinte</a>";
}
$str=$str."</td>";
$str=$str."<td align='right' valign='top' class='".$this->getStyle()."'>";
$str=$str."<form name='frmPage' action='".$_SERVER['PHP_SELF']."' method='get'>";
$str=$str."Página <input type='text' name='page' size='3' class='".$this->getStyle()."'> ";
$param=split("[& =]",$this->getParameter());
for($i=2;$i<=count($param);$i=$i+2) {
$str=$str."<input type='hidden' name='".$param[$i-1]."' value='".$param[$i]."'>";
}
$str=$str."<input type='submit' name='btnGo' value='Ok' class='".$this->getButtonStyle()."'>";
$str=$str."</form>";
$str=$str."</td>";
$str=$str."</tr></table>";
print $str;
}
function getPageNo() {
$str="";
$str=$str."<table width='200' border='0'><tr>";
$str=$str."<td width='30%' align='left' valign='top'>";
if($this->getPage()>1) {
$str=$str."<a href='".$_SERVER['PHP_SELF']."?page=".($this->getPage()-1).$this->getParameter()."' class='".$this->getStyle()."'>Anterior</a> ";
}
//modificado
for($i=$this->getPage();$i<=($this->getPage())+10;$i++) {
if($i==$this->getPage()) {
$str=$str."<span class='".$this->getActiveStyle()."'>".$i." </span>";
}
else {
$str=$str."<a href='".$_SERVER['PHP_SELF']."?page=".$i.$this->getParameter()."' class='".$this->getStyle()."'>".$i."</a> ";
}
}
//fim modificado
if($this->getPage()<$this->getNoOfPages()) {
$str=$str."<a href='".$_SERVER['PHP_SELF']."?page=".($this->getPage()+1).$this->getParameter()."' class='".$this->getStyle()."'>Seguinte</a>";
}
$str=$str."</td>";
$str=$str."<td align='right' valign='top' class='".$this->getStyle()."'>";
$str=$str."<form name='frmPage' action='".$_SERVER['PHP_SELF']."' method='get'>";
$str=$str."Página <input type='text' name='page' size='3' class='".$this->getStyle()."'> ";
$param=split("[& =]",$this->getParameter());
for($i=2;$i<=count($param);$i=$i+2) {
$str=$str."<input type='hidden' name='".$param[$i-1]."' value='".$param[$i]."'>";
}
$str=$str."<input type='submit' name='btnGo' value='Ok' class='".$this->getButtonStyle()."'>";
$str=$str."</form>";
$str=$str."</td>";
$str=$str."</tr></table>";
print $str;
}
Nao sei se bastará fazer esta modificação, mas esperimenta e diz-me como ficou
so modifique as vars do ciclo for.PHP://modificado for($i=$this->getPage();$i<=($this->getPage())+10;$i++) { if($i==$this->getPage()) { $str=$str."<span class='".$this->getActiveStyle()."'>".$i." </span>"; } else { $str=$str."<a href='".$_SERVER['PHP_SELF']."?page=".$i.$this->getParameter()."' class='".$this->getStyle()."'>".$i."</a> "; } } //fim modificado
deves colocar um link para a 1ª e a ultima pagina do genero: <Anterior 1 .. 15 16 17 18 19 20 21 22 23 24 25 .. 83 Proxima>
deves colocar um link para a 1ª e a ultima pagina do genero: <Anterior 1 .. 15 16 17 18 19 20 21 22 23 24 25 .. 83 Proxima>
//modificado
for($i=$this->getPage();$i<=($this->getPage())+10 && $i<=$this->getNoOfPages();$i++) {
if($i==$this->getPage()) {
$str=$str."<span class='".$this->getActiveStyle()."'>".$i." </span>";
}
else {
$str=$str."<a href='".$_SERVER['PHP_SELF']."?page=".$i.$this->getParameter()."' class='".$this->getStyle()."'>".$i."</a> ";
}
}
/* =====================================
* - - makes the html for nav links - -
*
* $page_num -> actual page
* $rows_page -> how many rows to show per page
* $total_page -> how many pages there are for the navigation
* $offset -> at wich row it starts the actual page
* $page_link -> the page link for navigation, including all querystring variables
* $show_links -> how many link to show before and after the actual page
* $pesquisar -> the search words, if the page is being viewed throw a search
* this criteria should pass among all pages like page number
*
* =========================================================*/
function nav_links ($page_num,$rows_page,$total_page,$offset,$page_link,$show_links,$pesquisar=''){
// print the link to access each page
$nav = '';
$total_show_links = 2 * $show_links;
// make a link navigation only
// if there are more than 1 page to show
if ($total_page > 1){
// criteria for a search
if ($pesquisar != '')
$pesquisar .= "&pesquisar=$pesquisar";
// shows link for 1st,previous,next,last, and for
// some pages before and some pages after the actual page
// shows 9 page links
$pages_before= $page_num - $show_links;
$pages_after = $page_num + $show_links;
// 1st page should be at least 1
if ($pages_before<1){
// $pages_after = $pages_after - $pages_before +1; // to continue showing all links
$pages_before = 1;
}
$pages_after=$pages_before + $total_show_links ;
// last page should be <= total pages
if ($pages_after > $total_page){
$pages_after=$total_page;
}
// shows 1st page link
if ($page_num>$show_links){
$nav = " <a href=\"{$page_link}1$pesquisar\">[Primeira]</a>";
}
else
$nav='[Primeira]';
// shows previous page link
if($page_num > 1){
$previous_page = $page_num -1;
$nav .= " <a href=\"{$page_link}$previous_page$pesquisar\">[<]</a>";
}
else
$nav .= ' [<]';
// make links for pages
for($page_actual = $pages_before; $page_actual <= $pages_after; $page_actual++)
{
if ($page_actual == $page_num)
{
$nav .= " $page_actual "; // no need to create a link to current page
}
else
{
$nav .= " <a href=\"{$page_link}$page_actual$pesquisar\">[$page_actual]</a>";
}
}
// shows next page link
if($page_num < $total_page){
$next_page = $page_num +1;
$nav .= " <a href=\"{$page_link}$next_page$pesquisar\">[>]</a>";
}
else{
$nav .=' [>]';
}
// shows last page link
if ($page_num < $total_page - $show_links)
$nav .= " <a href=\"{$page_link}$total_page$pesquisar\">[Última]</a>";
else
$nav .= ' [Última]';
}
return $nav;
}
// navigation variables
$page_num=1; // page where we are
$rows_total=0; // total rows
$rows_page=20; // how many rows per page
$total_page=0; // $rows_total / $rows_page
$offset = 0; // wich row to start the page
$show_links=2; // how many links to show before and after actual page
$nav='';
// check wich page we are, if not set it's 1st page
if (isset($_GET['page_num']))
$page_num=$_GET['page_num'];
$offset = ($page_num - 1) * $rows_page;
// get total rows
$query="SELECT id FROM actions";
$result = mysql_query ($query);
$rows_total=mysql_num_rows($result);
// get total pages
$total_page=ceil($rows_total / $rows_page);
$page_link = "$php_self?page=teste&page_num=";
$nav= nav_links($page_num,$rows_page,$total_page,$offset,$page_link,$show_links);