Jump to content

need help with Pagination problem


izlik

Recommended Posts

hello, this code http://nopaste.php-quake.net/9687  it's a tag system and on the bottom of the page there is a "next" to shift page if there is more then 30 images in total for the tag a user pressed. if i however have the tag "tags.php?=games" and press "next" it becomes "tags.php?pagenum=2" and everyting becomes messed up, do anyone know why? and could help me some this problem? :/ i cant get my head around it.

Link to comment
https://forums.phpfreaks.com/topic/77858-need-help-with-pagination-problem/
Share on other sites

You need to be passing the tag variable in the URL in all of your pagiation links - each time the page loads, it searches the database dependant on that variable, so it is always needed. You need to make your links like:

 

echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1&tag={$_GET['tag']}'> <<-First</a> ";

 

You'll need to change all the other links to also pass tag in the URL.

Hey again.

 

i added in what you said into the code so it looks like bellow, but when i now press "next" it will reload the page on page 1 al lthe time and not go to 2 or 3 "/tags.php?pagenum=2&tag=" <-- resault i get in the browser, no tag :/

 

<?	
    echo " --Page $pagenum of $last-- <p>";
   
    if ($pagenum == 1)
{
}
else
{
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1&tag={$_GET['tag']}'> <<-First</a> ";
echo " ";
$previous = $pagenum-1;
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous&tag={$_GET['tag']}'> <-Previous</a> ";
}

//just a spacer
echo " ---- ";

if ($pagenum == $last)
{
}
else {
$next = $pagenum+1;
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next&tag={$_GET['tag']}'>Next -></a> ";
echo " ";
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last&tag={$_GET['tag']}'>Last ->></a> ";
}
?>

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.