View Single Post
Old 01-02-2013, 08:19 PM   PM User | #1
milanello72
New Coder

 
Join Date: Feb 2012
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
milanello72 is an unknown quantity at this point
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-02-2013 at 11:45 PM..
milanello72 is offline   Reply With Quote