onefitchick Posted January 14, 2010 Share Posted January 14, 2010 Hi everyone, I'm having a problem where if I type a word into my search box, what comes up on the first result page is correct, but then when I click to the second result page, it returns everything that's in my database, and not just the search term anymore. I'm guessing there is some problem where the search term gets wiped out after the first page. index.php includes the search box, and searchgym.php is where the results should be and the page navigation. I would appreciate any help at all as I've been trying to figure this out for days (I'm new to php/mysql and didn't code this myself...). To see an example online, go to http://www.RateMyFitnessInstructor.com, click on the "find a gym" tab, and type in "world gym". The first page should have all "world gym", but page 2 and beyond have every gym in the database. Thanks! Quote Link to comment Share on other sites More sharing options...
Rizla Posted January 14, 2010 Share Posted January 14, 2010 When the script goes to the next page it probably loses the search terms did you include the search terms in your pagination urls??? and then get them with $_GET and do the check again ... Quote Link to comment Share on other sites More sharing options...
onefitchick Posted January 14, 2010 Author Share Posted January 14, 2010 I'm not sure. I don't really know anything about php. I will try to understand what you wrote. Thanks for the reply. Quote Link to comment Share on other sites More sharing options...
Rizla Posted January 14, 2010 Share Posted January 14, 2010 can you attatch the files you're having problems with, i'll have a look at it for you. Quote Link to comment Share on other sites More sharing options...
onefitchick Posted January 14, 2010 Author Share Posted January 14, 2010 I'm attaching the index file where the search box is located, and searchgym where page 2 does not include the search term, and also ps_pagination file. I think this is all that's involved? Thank you so much! [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
Rizla Posted January 14, 2010 Share Posted January 14, 2010 I'm not sure. I don't really know anything about php. I will try to understand what you wrote. Thanks for the reply. then how on earth did u wrote such complex php coding? Quote Link to comment Share on other sites More sharing options...
onefitchick Posted January 14, 2010 Author Share Posted January 14, 2010 I didn't write it . I paid someone to do it. Quote Link to comment Share on other sites More sharing options...
Rizla Posted January 14, 2010 Share Posted January 14, 2010 I didn't write it . I paid someone to do it. I thinks it's a simple mistake. He sets the $sql var to nothing on the pagination page. here: var $sql = ""; in the class PS_Pagination. Just delete that line an then try again and see if it works now. class PS_Pagination { var $php_self; var $rows_per_page = 10; //Number of records to display per page var $total_rows = 0; //Total number of rows returned by the query var $links_per_page = 5; //Number of links to display per page var $append = ""; //Paremeters to append to pagination links //==> delete this one: var $sql = ""; var $debug = false; var $conn = false; var $page = 1; var $max_pages = 0; var $offset = 0; Quote Link to comment Share on other sites More sharing options...
JAY6390 Posted January 14, 2010 Share Posted January 14, 2010 It looks more likely that the page number isn't being passed to/from the class, causing this issue, or it's not being inserted into the query. Don't bother with commenting out the $sql as that will cause issues. That is just the default value for that variable in the class and won't cause any bother Quote Link to comment Share on other sites More sharing options...
onefitchick Posted January 14, 2010 Author Share Posted January 14, 2010 I tried deleting the var $sql = ""; line, but it didn't work. Thank you Rizla. JAY6390 (or Rizla), how would I check for this: "It looks more likely that the page number isn't being passed to/from the class, causing this issue, or it's not being inserted into the query. " Quote Link to comment Share on other sites More sharing options...
Rizla Posted January 14, 2010 Share Posted January 14, 2010 How about this, the script states $conn but in the function it says $connection ??? actual: function PS_Pagination($connection, $sql, $rows_per_page = 10, $links_per_page = 5, $append = "") { Try: function PS_Pagination($conn, $sql, $rows_per_page = 10, $links_per_page = 5, $append = "") { Quote Link to comment Share on other sites More sharing options...
Rizla Posted January 14, 2010 Share Posted January 14, 2010 another thing actual: $pager = new PS_Pagination($db, $sql, $noofrecords,4, "param1=valu1¶m2=value2"); notice1: "valu1", shouldnt that be "value1" ??? notice2: $db, shouldnt that be $conn ??? Quote Link to comment Share on other sites More sharing options...
Catfish Posted January 14, 2010 Share Posted January 14, 2010 shouldn't "param=valu1¶m2=value2" not be a fixed string like that and have some variables defining the values appended to the url? for example... the search terms? ps: i didn't look at the code though - just assuming Quote Link to comment Share on other sites More sharing options...
onefitchick Posted January 14, 2010 Author Share Posted January 14, 2010 Thanks for the help, but sadly none of these worked. There shouldn't be any syntax problems in the ps_pagination file because that's a download you can take off the internet. I'll keep working on it. Quote Link to comment Share on other sites More sharing options...
onefitchick Posted January 14, 2010 Author Share Posted January 14, 2010 Thought this was interesting even though I haven't solved the problem...when I click on page 1, the last page is numbered 35 (a reasonable guess at how many pages my search term would output)… and when I click on page 2 or 3, the last page is numbered 98…(which is my entire database). Using View Source: Page 1 class="pagination_links"> First <<<span> 1 </span> <span><a href="/searchgym.php?page=2¶m1=valu1¶m2=value2">2</a></span> <span><a href="/searchgym.php?page=3¶m1=valu1¶m2=value2">3</a></span> <span><a href="/searchgym.php?page=4¶m1=valu1¶m2=value2">4</a></span> <a href="/searchgym.php?page=2¶m1=valu1¶m2=value2">>></a> <a href="/searchgym.php?page=35¶m1=valu1¶m2=value2">Last</a> </div> Page 3 class="pagination_links"> <a href="/searchgym.php?page=1¶m1=valu1¶m2=value2">First</a> <a href="/searchgym.php?page=2¶m1=valu1¶m2=value2"><<</a> <span><a href="/searchgym.php?page=1¶m1=valu1¶m2=value2">1</a></span> <span><a href="/searchgym.php?page=2¶m1=valu1¶m2=value2">2</a></span> <span> 3 </span> <span><a href="/searchgym.php?page=4¶m1=valu1¶m2=value2">4</a></span> <a href="/searchgym.php?page=4¶m1=valu1¶m2=value2">>></a> <a href="/searchgym.php?page=98¶m1=valu1¶m2=value2">Last</a> </div> Quote Link to comment 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.