Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2012
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem with pagination

    Hello! Please, excuse me because I will put a big code here, but I hope that you will understand me!
    I want to make a pagination and I addapt links for the files.
    ******************
    If I want to transform a link like
    Code:
    index.php?page=2&pagina=teams&id_team=1&numele=Juventus
    in a link like
    Code:
    /teams/1/Juventus.html?page=2
    ******************************
    In .htaccess I WILL HAVE
    Code:
    RewriteRule ^(([a-zA-Z0-9_-]+)/([0-9]+)/([a-zA-Z0-9.\s]+)/?.html$ index.php?pagina=$1&id_team=$2&numele=$3
    *****************************
    My file with the pagination is teams.php:
    Code:
    $sql29="select * from pozesq where id_team='$id_team'";
          $resursa29=mysql_query($sql29);
          $numar = mysql_num_rows($resursa29);
      
          $page = 1;                    //if no page var is given, default to 1.
          $adjacents = 3;
    
          $limit = 20;                                 //how many items to show per page
    
          if(isset($_GET['page']))
          {
           $page = $_GET['page']; 
    	   $lastpage = ceil($numar/$limit);   
               $start = ($page - 1) * $limit;
          }              //first item to display on this page
          else
          {
            $start = 0;
          } 
    	 
    	 
           $sql1="select * from pozesq where id_team='$id_team' order by id_pozasq asc LIMIT $start, $limit";
           $resursa1=mysql_query($sql1);
           $numar=mysql_num_rows($resursa1);
     
       ...... show photos ......	 
    
        $prev = $page - 1;                            //previous page is page - 1
        $next = $page + 1;                            //next page is page + 1
        $lastpage = ceil($total_pages/$limit);        //lastpage is = total pages / items per page, rounded up.
        $lpm1 = $lastpage - 1;
    
        $self = $_SERVER['PHP_SELF'];
        $targetpage = $self;
    	
    	 $path='pagina=teams&id_team='.$id_team.'&numele='.$numele.'';
    	 
    	 include('balariipagination.php');
    *********************************
    And the file balariipagination.php is
    Code:
    $pagination = "";
    
        if($lastpage > 1)
        {
            $pagination .= "<div class=\"pagination\">";
            //previous button
            if ($page > 1)
                $pagination.= "<a href=\"$targetpage?page=$prev&".$path."\">« previous</a>";
            else
                $pagination.= "<span class=\"disabled\">« previous</span>";
    
            //pages
            if ($lastpage < 7 + ($adjacents * 2))    //not enough pages to bother breaking it up
            {
                for ($counter = 1; $counter <= $lastpage; $counter++)
                {
                    if ($counter == $page)
                        $pagination.= "<span class=\"current\">$counter</span>";
                    else
                        $pagination.= "<a href=\"$targetpage?page=$counter&".$path."\">$counter</a>";
                }
             }
    .........
    .........
    .........
    etc
    ******************************
    **********************************
    I repeat that i want to obtain a link like
    /teams/1/Juventus.html?page=2
    How could i obtain that?
    1) in file teams.php i will change $path in ???
    Code:
    $path="/".$pagina."/".$id_team."/".$numele.".html";
    ********
    2) Must i change and $self = $_SERVER['PHP_SELF']; in teams.php in ....?
    Code:
    $_SERVER['REQUEST_URI']
    **********
    3) in this situation how it will change the file balariipagination.php ??? Tell me for exemple how will I change...?
    Code:
     href=\"$targetpage?page=$prev&".$path."\"
    ??
    thank you very much and i hope that you will understand my message!
    Last edited by milanello72; 01-03-2013 at 12:45 AM.

  • #2
    New Coder
    Join Date
    Feb 2012
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It works %50
    I have put:
    in .htaccess
    Code:
    RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)/([a-zA-Z0-9.\s]+)/?.html$ index.php?pagina=$1&id_squadra=$2&numele=$3 [L,QSA]
    and in balariipagination.php
    Code:
    $pagination.= "<a href=\"$targetpage?page=$next\">« previous</a>";
    And in teams.php
    Code:
    $self = $_SERVER['REQUEST_URI'];
    $targetpage = $self;
    But... i will go here calcioitalia/teams/1/Juventus F.C. Torino.html and after that I will enter in page=2 and it works
    (I will have calcioitalia/teams/1/Juventus F.C.Torino.html?page=2 )
    and if I will go in page=3 I will obtain this link calcioitalia/teams/1/Juventus F.C. Torino.html?page=2?page=3 with the content of page=2
    And it was set this
    Code:
    $_GET['page']=2?page=3
    so this is the problem:
    Code:
    $pagination.= "<a href=\"$targetpage?page=$next\">« previous</a>";
    how could i solve this problem?
    Last edited by milanello72; 01-03-2013 at 01:31 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •