Jump to content

[SOLVED] page pagination help


shadiadiph

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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.