nickd_101 Posted August 22, 2006 Share Posted August 22, 2006 Hi,I'm working on a script that will paginate results of a query submitted by a form. Basically, I have the query "SELECT * FROM property WHERE City ='$city' AND Rooms='$rooms'the two variables $rooms and $city are passed to the script from a preceding search form. Everything works ok until i seek to paginate the results, to reduce the pages sizes. I know where the problem is, it's just trying to get around it that's causing me problems! What's happening is once a user clicks to view the next page, I receive the error:Notice: Undefined index: City in C:\Server\Apache2\htdocs\Test2\search_basic.php on line 34I understand that this is because the form is not used to pass the data onto the PHP script once i open the next page, so I added the following to my scriptif ($pageno != 1){ $city = $_GET['City']; $rooms = $_GET['Rooms'];}else{$city = $_REQUEST['City'];$rooms = $_REQUEST['Rooms'];}and made my page navigation links:<a href='search_basic.php?pageno=$nextpage?City=$city?Rooms=$rooms'>NEXT</a>I thought that this would then pass the values for City and Rooms on from the hyperlink back into the script, as it realises that the page number is no longer 1 (i've checked this using an echo). I think the problem in passing the values on, but i'm fairly new to PHP so i'm struggling to find a workaroundAny ideas?Thanks for your assistance,Nick Quote Link to comment https://forums.phpfreaks.com/topic/18289-mysql-result-pagination-problem/ Share on other sites More sharing options...
logu Posted August 22, 2006 Share Posted August 22, 2006 hi the problem may be in passing the variableu r using "<a href='search_basic.php?pageno=$nextpage?City=$city?Rooms=$rooms'>NEXT[/url]"it should be use '&' instead of '?' after the first parameter eg like" search_basic.php?pageno=$nextpage&City=$city&Rooms=$rooms " Quote Link to comment https://forums.phpfreaks.com/topic/18289-mysql-result-pagination-problem/#findComment-78556 Share on other sites More sharing options...
ober Posted August 22, 2006 Share Posted August 22, 2006 <a href='search_basic.php?pageno=$nextpage&City=$city&Rooms=$rooms'>NEXT</a>[nobbc]Your problem is that you were using ? between all the variables. you need to use a ? after the base php file and then & between everything else. And & is what you should be using for valid markup. That is the HTML equivalent of the ampersand.[/nobbc] Quote Link to comment https://forums.phpfreaks.com/topic/18289-mysql-result-pagination-problem/#findComment-78557 Share on other sites More sharing options...
nickd_101 Posted August 22, 2006 Author Share Posted August 22, 2006 Thanks for the help.Worked perfectly! Quote Link to comment https://forums.phpfreaks.com/topic/18289-mysql-result-pagination-problem/#findComment-78565 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.