Jump to content

Recommended Posts

I have been using the pagination from the tutorial in here problem is on one page I have two tables that both have te pagination on them and when I click on link two both tables jump to link 2 which variable in this do i need to change for this to work do i need to rename all the $totalpages or just $x i tried it once and it didn't work.

 

$range = 3; 

if ($currentpage ==2) {   
   $prevpage = $currentpage - 1;     
   echo "<td> <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'>PREVIOUS</a> </td>";   
}   
    
if ($currentpage > 2) {   
   echo " <tr><td><a href='{$_SERVER['PHP_SELF']}?currentpage=1'>FIRST</a></td> ";   
   $prevpage = $currentpage - 1;     
   echo " <td><a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'>PREVIOUS</a><td> ";   
}   
   
for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {   
   if (($x > 0) && ($x <= $totalpages)) {      
      if ($x == $currentpage) {     
         echo "<td class='sel'> [<b>$x</b>]</td> ";     
      } else {   
     echo " <td><a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a></td> ";   
      }    
   }     
}  
if ($currentpage == $totalpages -1) {       
   // echo forward link for lastpage   
   echo "<td> <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>NEXT</a> </td>";   
} 

else { 

if ($currentpage != $totalpages) {   
   // get next page   
   $nextpage = $currentpage + 1;   
    // echo forward link for next page    
   echo " <td><a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>NEXT</a></td> ";   
   // echo forward link for lastpage   
   echo " <td><a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>LAST</a></td> ";   
} 
}

Link to comment
https://forums.phpfreaks.com/topic/148570-solved-page-pagination-help/
Share on other sites

Hi,

I building a photographic website and have a database in with the details want to paginate the results by category.

 

I have run through the pagination tutorial and I think that I understand it.

I have added the code to my page - see attached.

 

And running it I get

"Parse error: syntax error, unexpected $end in /home/outwell1/public_html/beta/photogalpag.php on line 330"

 

Error message. - line 330 is the last line of the page </html>

 

Can any one help please?

 

Thanks

 

[attachment deleted by admin]

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.