Forum Moderators: coopster

Message Too Old, No Replies

Paging of search results...

         

AlexLee

12:06 pm on Feb 16, 2005 (gmt 0)

10+ Year Member



Hi, I need to do some paging for my search results after a form submition.

I had a code with me now. But it does not carry the $keyword = $_POST['keyword'] forward to the next page.

Therefore everytime when I am suppose to reach the end of the result. It generate all the page too with the remaining items in the database.

I know I did not pass the $keyword to the NEXT page. But I had no idea how...

My paging only works if I hard code the SELECT item FROM table WHERE column LIKE '%KEYWORD%'
Instead of $keyword.

hakre

12:23 pm on Feb 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



if you want to utilize the POST method on multiple pages, every page needs to be requested by a form with method="post" instead of a simple GET request. then
$_POST['keyword']
will be set on subsequent pages, too.

AlexLee

12:31 pm on Feb 16, 2005 (gmt 0)

10+ Year Member



I am already doing that...

The thing is when doing paging.

When going into another page in pagination, only the content changes right?

It is here that I lost the initial value of $keyword. I had submited from my form to page 1. How do I carry $keyword forward to other pages?

hakre

1:28 pm on Feb 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How do I carry $keyword forward to other pages?

2 ways:

1.) post
let the user request the next page by pressing a submit button and having the value of the next page and the keyword in the form:
<form method="post" action="list.php">
<input type="hidden" name="keyword" value="keyword" />
<input type="hidden" name="page" value="2" />
<input type="submit" name="act_pn" value="&lt;" />
</form>

2.) get

http://..../list.php?keyword=keyword&page=2

now use $keyword = $_REQUEST['keyword'] instead of $_POST['keyword'].

do you understand what i mean?

jatar_k

5:34 pm on Feb 16, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you could also try any of these threads

pagination [google.com]