Jump to content

Archived

This topic is now archived and is closed to further replies.

netfrugal

Paginating issue

Recommended Posts

I have 2 pages.  Form.php  & Paginate.php

I enter the username into the form.php and it sends me over to paginate.php where it looks for records with the username I chose.

I can see all the results on Paginate.php, but if I click to go to the next page (paginate.php?page=2)  everything goes blank!

Do the search parameters get lost after one page? 

Any help would be appreciated!

thanks!

Share this post


Link to post
Share on other sites
[quote author=netfrugal link=topic=110978.msg449400#msg449400 date=1160417366]
Do the search parameters get lost after one page? 
[/quote]

Yes, unless you save them in a session variable, or pass them in the URL along with the page number (I think the second is probably preferable in your case).

Say your form submits with a URL like this:
[color=green]http://www.mydom.com/paginate.php?cat=shirts&sort=asc[/color]

Then the links in your paginate page should look a little like this:
[code=php:0]
echo <<<HTML
<a href="paginate.php?cat={$_GET['cat']}&sort={$_GET['sort']}&page={$i}">$i</a>
HTML;
[/code]

This would take you to the following url:
[color=green]http://www.mydom.com/paginate.php?cat=shirts&sort=asc&page=2[/color]

I've used heredoc syntax to escape the HTML above, if you're unaware of this, look it up here: [url=http://uk.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc]heredoc[/url]

Regards
Huggie

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.