Pages help...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    this might be bit complicated but shows 4 page number before and after current page but only if they exist

    PHP Code:
    $num_pages ceil($smileys/$imagesperpage);
    if (
    $_GET['page'] - 1$pagemin 1;
    else 
    $pagemin $_GET['page'] - 4;
    $maxPage $num_pages;
    if (
    $_GET['page'] + $maxPage$pagemax $maxPage;
    else 
    $pagemax $_GET['page'] + 4;
    if (
    $_GET['page'] > 1$controls .= "<a href=\"".$action."extras".$mod."smileys&amp;page=".($_GET['page']-1)."\">Prev</a>\n";
    else 
    $controls .= "Prev\n";
    for(
    $page $pagemin$page <= $pagemax$page++) 
    {
    if (
    $page == $_GET['page']) $controls .= $page \n";
    else 
    $controls .= " <a href=\"".$action."extras".$mod."smileys&amp;page=$page\">$page</a> \n";
    }
    if (
    $_GET['page'] < $num_pages$controls .= "<a href=\"".$action."extras".$mod."smileys&amp;page=".($_GET['page']+1)."\">Next</a>";
    else 
    $controls .= "Next";
    if (
    $page || $smileys > ($page*$imagesperpage)) $controls .= "<br/>"

    Comment


      #17
      PHP Code:
      <?
      // wap-landz.tk
      function pagination($total,$current,$perpage='10',$url=''){
      if($total >= $perpage){
      $totalpages=round($total/$perpage);
      $totalpages2=$total/$perpage;
      if($totalpages2>$totalpages)
      $totalpages=$totalpages+1;
      $pagesar['First'] = "1";
      if($current > 1){
      $cd=$current-1;
      $pagesar['Prev'] = $cd;
      if($cd==1)
      $st=1;
      else if($cd==2)
      $st=$cd-1;
      else if($cd>=3)
      $st=$cd-2;
      for($i=$st;$i<=$cd;$i++){
      $pagesar[$i] = $i;
      }
      }
      if($totalpages > $current+4)
      $finalstop=$current+4;
      else
      $finalstop=$totalpages;
      for($j=$current;$j<=$finalstop;$j++){
      $pagesar[$j] = $j;
      }
      if($totalpages > $current)
      $pagesar['Next'] = $current+1;
      $pagesar['Last'] = $totalpages;
      }else{
      $pagesar['1'] = "1";
      }
      if(is_array($pagesar))
      {
      print "Pages:&nbsp;&nbsp;";
      foreach($pagesar as $key => $val)
      {
      if($val == $current)
      { print $key."&nbsp;&nbsp;"; }
      else{ print "<a href=\"".$url."?page=$val\">".$key."</a>&nbsp;&nbsp;"; }
      }
      }
      }
      // how to use
      $c=$_GET['page'];
      if (!$c) $c=1;
      pagination(24,$c,5);
      ?>

      Comment


        #18
        Originally posted by hidden
        juz copy it from any toplist sccript
        dont have any thanx ori and ionutvmi...i made the code here it is i use a function

        function pages($num_pages, $page, $link )
        {
        if($num_pages > 1)
        {
        if($page > 1 )
        {
        $ppage = $page-1;
        echo '<a href="'.$link.'&amp;page='.$ppage.'">&#171;</a>';
        echo ' | ';
        }else{
        echo '&#171;';
        echo ' | ';
        }
        for ($i = 1; $i <= $num_pages; $i++)
        {
        if($page == $i)
        {
        echo '<b>'.$i.'</b>';
        echo ' | ';
        }else{
        echo '<a href="'.$link.'&amp;page='.$i.'">'.$i.'</a>';
        echo ' | ';
        }}
        if(($page < $num_pages) && ($num_pages > 1))
        {
        $npage = $page+1;
        echo '<a href="'.$link.'&amp;page='.$npage.'">&#187;</a>';
        }else{
        echo '&#187;';
        }
        }
        }

        Comment


          #19
          Originally posted by ionutvmi View Post
          PHP Code:
          <?
          // wap-landz.tk
          function pagination($total,$current,$perpage='10',$url=''){
          if($total >= $perpage){
          $totalpages=round($total/$perpage);
          $totalpages2=$total/$perpage;
          if($totalpages2>$totalpages)
          $totalpages=$totalpages+1;
          $pagesar['First'] = "1";
          if($current > 1){
          $cd=$current-1;
          $pagesar['Prev'] = $cd;
          if($cd==1)
          $st=1;
          else if($cd==2)
          $st=$cd-1;
          else if($cd>=3)
          $st=$cd-2;
          for($i=$st;$i<=$cd;$i++){
          $pagesar[$i] = $i;
          }
          }
          if($totalpages > $current+4)
          $finalstop=$current+4;
          else
          $finalstop=$totalpages;
          for($j=$current;$j<=$finalstop;$j++){
          $pagesar[$j] = $j;
          }
          if($totalpages > $current)
          $pagesar['Next'] = $current+1;
          $pagesar['Last'] = $totalpages;
          }else{
          $pagesar['1'] = "1";
          }
          if(is_array($pagesar))
          {
          print "Pages:&nbsp;&nbsp;";
          foreach($pagesar as $key => $val)
          {
          if($val == $current)
          { print $key."&nbsp;&nbsp;"; }
          else{ print "<a href=\"".$url."?page=$val\">".$key."</a>&nbsp;&nbsp;"; }
          }
          }
          }
          // how to use
          $c=$_GET['page'];
          if (!$c) $c=1;
          pagination(24,$c,5);
          ?>
          how do i make this work with session id?

          Comment

          Working...
          X