izlik Posted November 18, 2007 Share Posted November 18, 2007 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 More sharing options...
only one Posted November 18, 2007 Share Posted November 18, 2007 Why do you want to add '?=games' to the querystring? It wont do anything. Link to comment https://forums.phpfreaks.com/topic/77858-need-help-with-pagination-problem/#findComment-394077 Share on other sites More sharing options...
GingerRobot Posted November 18, 2007 Share Posted November 18, 2007 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. Link to comment https://forums.phpfreaks.com/topic/77858-need-help-with-pagination-problem/#findComment-394084 Share on other sites More sharing options...
only one Posted November 18, 2007 Share Posted November 18, 2007 echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1&tag={$_GET['tag']}'> <<-First</a> "; That wont be valid HTML.. echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1&tag={$_GET['tag']}'> <<-First</a> "; Link to comment https://forums.phpfreaks.com/topic/77858-need-help-with-pagination-problem/#findComment-394085 Share on other sites More sharing options...
izlik Posted November 18, 2007 Author Share Posted November 18, 2007 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> "; } ?> Link to comment https://forums.phpfreaks.com/topic/77858-need-help-with-pagination-problem/#findComment-394098 Share on other sites More sharing options...
izlik Posted November 19, 2007 Author Share Posted November 19, 2007 anyone around still that think they could help out? :/ i would be very very much greatfull Link to comment https://forums.phpfreaks.com/topic/77858-need-help-with-pagination-problem/#findComment-394659 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.