Pages help...

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

    Pages help...

    how can i make my pages links look like this when i want to another page

    eg: <- Previous [1] [2] [3] [4] [5] Next ->

    please help me out on this

    #2
    something like:
    PHP Code:
    echo '<-&lt; <a href="'.$_server['php_self'].'?page='.$page-1.'">Previous </a>';
    for (
    $i $page$i <= $page+5$i++) {
        echo 
    '<a href="'.$_server['php_self'].'?page='.$i.'">['.$i.'] </a> ';
    }
    echo 
    '<a href="'.$_server['php_self'].'?page='.$page+1.'">Next -&gt; </a>'
    Last edited by something else; 19.07.10, 22:56.

    Comment


      #3
      Originally posted by something else View Post
      something like:
      PHP Code:
      echo '<-&lt; <a href="'.$_server['php_self'].'?page='.$page-1.'">Previous </a>';
      for (
      $i $page$i <= $page+5$i++) {
          echo 
      '<a href="'.$_server['php_self'].'?page='.$i.'">['.$i.'] </a> ';
      }
      echo 
      '<a href="'.$_server['php_self'].'?page='.$page+1.'">Next -&gt; </a>'
      hey thanx so much but i dnt understand that coding could u do it like this please?

      if($page>1)

      {

      $ppage = $page-1;

      echo "<a href=\"index.php?page=$ppage\">«Prev</a> ";

      }

      if($page<$total_pages)

      {

      $npage = $page+1;

      echo "<a href=\"index.php?page=$npage\">Next»</a>";

      }

      Comment


        #4
        PHP Code:
        if($page>1){
        $ppage $page-1;
        echo 
        "<a href=\"index.php?page=$ppage\">«Prev</a> ";
        }
        $capped_pages $total_pages-4;
        if(
        $pages<$capped_pages){
        for (
        $i $ppage$i <= ($page+5); $i++) {            //previous page added here also ...so if on page 3 it shows pages 23456
            
        echo "<a href=\"index.php?page=$i\">[$i] </a> "
        }
        }
        else if(
        $page==1){
        for (
        $i $page$i <= ($page+5); $i++) { 
            echo 
        "<a href=\"index.php?page=$i\">[$i] </a> "
        }
        }
        else{
        for (
        $i = ($total_pages-5); $i <= ($page+5); $i++) {      //show total pages (dont go over (capped))
            
        echo "<a href=\"index.php?page=$i\">[$i] </a> "
        }
        }

        if(
        $page<$total_pages){
        $npage $page+1;
        echo 
        "<a href=\"index.php?page=$npage\">Next»</a>";

        Last edited by something else; 20.07.10, 01:19.

        Comment


          #5
          Originally posted by something else View Post
          PHP Code:
          if($page>1){
          $ppage $page-1;
          echo 
          "<a href=\"index.php?page=$ppage\">«Prev</a> ";
          }
          $capped_pages $total_pages-4;
          if(
          $pages<$capped_pages){
          for (
          $i $ppage$i <= ($page+5); $i++) {            //previous page added here also ...so if on page 3 it shows pages 23456
              
          echo "<a href=\"index.php?page=$i\">[$i] </a> "
          }
          }
          else if(
          $page==1){
          for (
          $i $page$i <= ($page+5); $i++) { 
              echo 
          "<a href=\"index.php?page=$i\">[$i] </a> "
          }
          }
          else{
          for (
          $i = ($total_pages-5); $i <= ($page+5); $i++) {      //show total pages (dont go over (capped))
              
          echo "<a href=\"index.php?page=$i\">[$i] </a> "
          }
          }

          if(
          $page<$total_pages){
          $npage $page+1;
          echo 
          "<a href=\"index.php?page=$npage\">Next»</a>";


          thank u so much am going to try it....

          Comment


            #6
            having a problem with the code when nothing is on the page its showing [][1][2][3][4][5] its showing that when nothing is on the page i want it to be blank until there is something on the page it will show [1][2]etc....please fix

            Comment


              #7
              PHP Code:
              if($page>1){ 
              $ppage $page-1
              echo 
              "<a href=\"index.php?page=$ppage\">«Prev</a> "

              $capped_pages $total_pages-4
              if(
              $pages<$capped_pages){ 
              for (
              $i $ppage$i <= ($page+5); $i++) {            //previous page added here also ...so if on page 3 it shows pages 23456 
                  
              echo "<a href=\"index.php?page=$i\">[$i] </a> ";  


              else if(
              $page==1){ 
              for (
              $i $page$i <= ($page+5); $i++) {  
              if(
              $i<=$total_pages){
                  echo 
              "<a href=\"index.php?page=$i\">[$i] </a> ";  
              }


              else{ 
              for (
              $i = ($total_pages-5); $i <= ($page+5); $i++) {      //show total pages (dont go over (capped)) 
                  
              echo "<a href=\"index.php?page=$i\">[$i] </a> ";  



              if(
              $page<$total_pages){ 
              $npage $page+1
              echo 
              "<a href=\"index.php?page=$npage\">Next»</a>"

              Comment


                #8
                still doesnt work...i thank u for helping i have 10 messages per page and there is only 2 messages on the first page and it that code is showing this

                [][1][2][3][4][5][6]

                Comment


                  #9
                  try
                  PHP Code:
                  if($page>1){  
                  $ppage $page-1;  
                  echo 
                  "<a href=\"index.php?page=$ppage\">«Prev</a> ";  
                  }  
                  $capped_pages $total_pages-4
                  if(
                  $page==1){  
                  for (
                  $i $page$i <= ($page+5); $i++) {   
                  if(
                  $i<=$total_pages){ 
                      echo 
                  "<a href=\"index.php?page=$i\">[$i] </a> ";   

                  }  

                  else if(
                  $page<$capped_pages){  
                  for (
                  $i $ppage$i <= ($page+5); $i++) {            //previous page added here also ...so if on page 3 it shows pages 23456  
                  if($i<=$total_pages){
                      echo 
                  "<a href=\"index.php?page=$i\">[$i] </a> ";   
                  }
                  }  
                  }  
                    
                  else{  
                  for (
                  $i = ($total_pages-5); $i <= ($page+5); $i++) {      //show total pages (dont go over (capped))  
                      
                  echo "<a href=\"index.php?page=$i\">[$i] </a> ";   
                  }  
                  }  

                  if(
                  $page<$total_pages){  
                  $npage $page+1;  
                  echo 
                  "<a href=\"index.php?page=$npage\">Next»</a>";  

                  Comment


                    #10
                    yeah this seems to work....thanx...but the problem now is that when am on the last page for example page 4 is the last page it shows this Prev [-1][0][1][2][3][4][5][6][7][8][9] Next
                    Last edited by wap_king; 20.07.10, 17:40.

                    Comment


                      #11
                      $i is just a varible it could be anything eg:
                      for ($something_else = $ppage; $something_else <= ($page+5); $something_else++) {

                      Comment


                        #12
                        oh yeah i get it did u see my last post about the code?

                        Comment


                          #13
                          check this it wil help u i am uploading pager files and its examples
                          Attached Files

                          Comment


                            #14
                            thanx bro hope it helps me thanx again...

                            Comment


                              #15
                              can any one help me a example of whati want is right here on the right at the bottom where Page 1 of 2 [1][2][>][Last>>] thats how i want it

                              Comment

                              Working...
                              X