Page 1 of 1

Problem related to search code and pagination on the search

Posted: Thu Jun 12, 2008 1:40 am
by tiachd5
Hi All,

I am getting a problem in my php script, I have made a search when I search by name or country name or company name, the first time it shows the records as well as the total no. of pages having that type of record but when i click on the 2nd or 3rd .... page of pagination it left that condition and shows me all the records as I have set for the default page when it loads like all the records with all the pages. But I want those records as I searched for with that page no. like 2, or 3.

If anybody can help me in solving this problem.

With regards,
tiachd

Re: Problem related to search code and pagination on the search

Posted: Thu Jun 12, 2008 2:14 am
by deejay
could you post your code, using the 'Code' button. Thanks

Re: Problem related to search code and pagination on the search

Posted: Thu Jun 12, 2008 4:46 am
by VladSun
deejay wrote:could you post your code, using the 'Code' button. Thanks
... using [ php ] your code here [ /php ] (without spaces in tags). Otherwise it looses its syntax highlighting and is less readable

Re: Problem related to search code and pagination on the search

Posted: Thu Jun 12, 2008 4:51 am
by superdezign
tiachd5 wrote:but when i click on the 2nd or 3rd .... page of pagination it left that condition and shows me all the records as I have set for the default page when it loads like all the records with all the pages. But I want those records as I searched for with that page no. like 2, or 3.
You have to give the pagination links the ability to know which search query is the current query being performed. In other words:

Code: Select all

// Bad
echo '<a href="' . $searchUrl . '?page=' . $pageNumber . '">' . $pageNumber . '</a>';

Code: Select all

// Good
echo '<a href="' . $searchUrl . '?page=' . $pageNumber . '&query=' . $searchQuery . '">' . $pageNumber . '</a>';

Re: Problem related to search code and pagination on the search

Posted: Thu Jun 12, 2008 5:17 am
by tiachd5
I have tried this:

echo '<a href="' . $searchUrl . '?page=' . $pageNumber . '&query=' . $searchQuery . '">' . $pageNumber . '</a>';

not not got the desired result the problem persist still as it was earlier

Re: Problem related to search code and pagination on the search

Posted: Thu Jun 12, 2008 6:22 am
by superdezign
Do not simply "try it." Implement it. It's not a magic solution, it's a concept.

Re: Problem related to search code and pagination on the search

Posted: Thu Jun 12, 2008 7:11 am
by deejay
'superdesign' was giving you some food for thought rather than an answer. Afterall we do not know the code you are using to achive pagination. There's always more than 1 way to skin a cat.
is the page number showing in the url after clicking on the page number link.


Vladsun: Sorry, I stand corrected :)