Problem related to search code and pagination on the search

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tiachd5
Forum Newbie
Posts: 2
Joined: Thu Jun 12, 2008 1:31 am

Problem related to search code and pagination on the search

Post 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
User avatar
deejay
Forum Contributor
Posts: 201
Joined: Wed Jan 22, 2003 3:33 am
Location: Cornwall

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

Post by deejay »

could you post your code, using the 'Code' button. Thanks
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

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

Post 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
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

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

Post 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>';
tiachd5
Forum Newbie
Posts: 2
Joined: Thu Jun 12, 2008 1:31 am

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

Post 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
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

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

Post by superdezign »

Do not simply "try it." Implement it. It's not a magic solution, it's a concept.
User avatar
deejay
Forum Contributor
Posts: 201
Joined: Wed Jan 22, 2003 3:33 am
Location: Cornwall

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

Post 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 :)
Post Reply