Photobrad.com Posted June 9, 2007 Share Posted June 9, 2007 Need some help that should be pretty basic, but it's stumping me. I have a page that's displaying data from the database. I have a pull-down menu that let's the user select specific fields to display all entries that share fields. I use the GET form method, and the URL looks like this: /display.php?search=name In the code I have a pagination setup (for "next page" and "previous page" text links) however those links don't seem to add their string to the end of the existing search string. Instead of /display.php?search=name&pageno=2 (which works if I type it in) I get /display.php?page=2 and by doing that I lose the search criteria and it displays all items in the database (which is the default if no search is defined). The pagination PHP code uses this for the link is: <a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage'>NEXT</a> Even when I remove the $_SERVER and PHP_SELF references, it doesn't add the pageno= string to the existing ?search= string. Is there a way to extract the full URL string and append the &pageno string to it? In short, I need a way to retain the existing "?search=" values in the URL while adding "&pageno=" to the end. Did that make any sense? Any assistance would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/54855-adding-new-string-values-to-existing-url-string/ Share on other sites More sharing options...
chigley Posted June 9, 2007 Share Posted June 9, 2007 <?php $var = "/display.php?search=name"; $var .= "&pageno={$nextpage}"; // Notice the . before the = ?> Quote Link to comment https://forums.phpfreaks.com/topic/54855-adding-new-string-values-to-existing-url-string/#findComment-271297 Share on other sites More sharing options...
Photobrad.com Posted June 9, 2007 Author Share Posted June 9, 2007 Thanks, chigley! Does it matter where that code goes? Quote Link to comment https://forums.phpfreaks.com/topic/54855-adding-new-string-values-to-existing-url-string/#findComment-271446 Share on other sites More sharing options...
chigley Posted June 9, 2007 Share Posted June 9, 2007 Add it before where you echo/print the URL. Quote Link to comment https://forums.phpfreaks.com/topic/54855-adding-new-string-values-to-existing-url-string/#findComment-271461 Share on other sites More sharing options...
Photobrad.com Posted June 17, 2007 Author Share Posted June 17, 2007 Worked like a charm! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/54855-adding-new-string-values-to-existing-url-string/#findComment-276175 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.