gouc89 Posted October 19, 2012 Share Posted October 19, 2012 I'm trying to get all of my records to display in my PrimaryContent DIV, but only the first one does. When you click on any other pages, they display on a completely separate page. I was told to Google "passing multiple variables in a query string" but there was so much coding that I was completely lost. I was also told, "Find the place in the code where the page=xxx is set in the URL (First << 1 2 3 etc.). Add your Menukey to the Query String. Every time the page reloads, check for the MenuKey and let the Function check for the Page Number." The part I don't really understand is how I add my menukey to the query string. Any help would be appreciated. If you need to see any specific code let me know. My page is here so you can see for yourself: http://itd1.cincinnatistate.edu/php_vondrelld/index.php?menukey=8 Scroll to the bottom and click another page and you'll see what I mean. Thanks so much! Quote Link to comment https://forums.phpfreaks.com/topic/269687-pagination-help/ Share on other sites More sharing options...
ManiacDan Posted October 19, 2012 Share Posted October 19, 2012 The "menukey" you see in your query string is...the menukey from the query string. The query string is the last bit of the URL. If you need to pass multiple variables in a query string, you separate them with an ampersand: yourfile.php?menukey=8&page=3 Quote Link to comment https://forums.phpfreaks.com/topic/269687-pagination-help/#findComment-1386385 Share on other sites More sharing options...
gouc89 Posted October 19, 2012 Author Share Posted October 19, 2012 I see that, but when I go to index.php?menukey=8&page=3, still the first page loads. Where do I change it in the code? For instance, right now I've got this code for clicking "Next": return '<a href="'.$this->php_self.'?page='.($this->page+1).'">'.$tag.'</a>'; Do I change something in there? Or somewhere in the paginate function? Quote Link to comment https://forums.phpfreaks.com/topic/269687-pagination-help/#findComment-1386390 Share on other sites More sharing options...
akphidelt2007 Posted October 19, 2012 Share Posted October 19, 2012 $this->php_self is incorrect. Depending on your setup it might be easiest just to plug in a href='http://yoursite.com/index.php?menukey=8&page=2' Quote Link to comment https://forums.phpfreaks.com/topic/269687-pagination-help/#findComment-1386407 Share on other sites More sharing options...
ManiacDan Posted October 19, 2012 Share Posted October 19, 2012 Nothing in code happens "automatically," you can't just add "page=2" to your code and expect it to display the second page, you actually have to write code which processed $_GET['page']. Did you do that? Quote Link to comment https://forums.phpfreaks.com/topic/269687-pagination-help/#findComment-1386413 Share on other sites More sharing options...
DavidAM Posted October 19, 2012 Share Posted October 19, 2012 $this->php_self is incorrect. Depending on your setup it might be easiest just to plug in a href='http://yoursite.com/index.php?menukey=8&page=2' $this->php_self might be unsafe, depending on what that class is doing with it. There are known exploits with using $_SERVER['PHP_SELF'] directly, but if the class is handing that, then it might be safe. I see that, but when I go to index.php?menukey=8&page=3, still the first page loads. Where do I change it in the code? Your script needs to pick up the page value that is requested using $_GET['page'] and use that to select the data for the page. Without seeing some code, we can't really tell where you are going wrong. Quote Link to comment https://forums.phpfreaks.com/topic/269687-pagination-help/#findComment-1386414 Share on other sites More sharing options...
gouc89 Posted October 19, 2012 Author Share Posted October 19, 2012 Here's the code I have where $_GET['page'] is: function PS_Pagination($connection, $sql, $rows_per_page = 10, $links_per_page = 5) {$this->conn = $connection; $this->sql = $sql; $this->rows_per_page = $rows_per_page; $this->links_per_page = $links_per_page; $this->php_self = htmlspecialchars($_SERVER['PHP_SELF']); if(isset($_GET['page'])) { $this->page = intval($_GET['page']); } Quote Link to comment https://forums.phpfreaks.com/topic/269687-pagination-help/#findComment-1386423 Share on other sites More sharing options...
akphidelt2007 Posted October 19, 2012 Share Posted October 19, 2012 $this->php_self might be unsafe, depending on what that class is doing with it. There are known exploits with using $_SERVER['PHP_SELF'] directly, but if the class is handing that, then it might be safe. What I meant by it's incorrect is it's coming up with the wrong url. When you click on the page # it sends you to a completely different url. Quote Link to comment https://forums.phpfreaks.com/topic/269687-pagination-help/#findComment-1386425 Share on other sites More sharing options...
gouc89 Posted October 19, 2012 Author Share Posted October 19, 2012 Right, and I'm not sure how to sync menukey in with it. I understand the URL part, just not what to do with $_GET['page'] Quote Link to comment https://forums.phpfreaks.com/topic/269687-pagination-help/#findComment-1386442 Share on other sites More sharing options...
gouc89 Posted October 20, 2012 Author Share Posted October 20, 2012 Anybody else have any advice? I can always post more code if that's the issue. Quote Link to comment https://forums.phpfreaks.com/topic/269687-pagination-help/#findComment-1386592 Share on other sites More sharing options...
PFMaBiSmAd Posted October 20, 2012 Share Posted October 20, 2012 To build your pagination links, while keeping any existing get parameters or letting a different section of your code set their own get parameters, see the use of http_build_query in the following pagination example - http://forums.phpfreaks.com/topic/268497-pagination/page__hl__+http_build_query#entry1378864 Quote Link to comment https://forums.phpfreaks.com/topic/269687-pagination-help/#findComment-1386596 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.