basicly you need to do select .......... limit $ptr, 1
and links prev = $ptr-1 (if $ptr!=0) and next = $ptr +1 (if $ptr < select count(*))

Petre Agenbag wrote:

Rick, thanks, I will check the lists, but I'm not sure that will resolve my problem, I
don't want to limit the display in the initial result set, I want to
have a page that lists ALL the hits above each other, and it's only once
you click through to the next page that I want to start "walking"
through the list.

Anyway, I might be missing the point you are trying to make her, so I
will first go and do some research before I ask a bunch of questions you
have already answered for me...

Ta

On Tue, 2002-10-29 at 15:33, Rick Emery wrote:

This is a common requirement; check the archives and/or php.net, phpbuilder, etc.

What you will do is use mysql's LIMIT parameter on your select; go to mysql.com to read
about it.
Lets assume you wish to display 20 lines per page; assume you use a pointer, $ptr, to
determine where you are in a search:

$query = "SELECT * FROM mytable WHERE some criteria LIMIT $ptr,20";
mysql_query($query) or die(mysql_error());

To go to the next page, create a hyperlink:
$ptrN = $ptr + 20;
<A href="this_script.php?ptr=$ptrN">Next</A>
$ptrP = $ptr - 20;
<A href="this_script.php?ptr=$ptrP>Previous</A>

I leave the details to you.

----- Original Message -----
From: "Petre Agenbag" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, October 29, 2002 6:06 AM
Subject: [PHP] back and forward through a result query


Hi
I need to do the following, and have a slight idea of how to do it, but
I'm not sure...

I want to do a "select id from table where something = "whatever" ",
then I will display all the "hits" from that query as links to a
"display" page, sending along the id's of the row.

On that next page, I will use that id to retrieve the relevant data to
display for that specific record, but, I want to have a previous|next
function, that will display the relevant data of the previous or next
record as was displayed on the original page that showed the list of
"hits". So I *think* I should create an array containing all the id's of
that query, and send it along with the clickthrough to the "display"
page and then from there use the array functions "next" and "prev" to
get the id's directly adjacent to the one I currently have, but I'm not
sure if this is the best way to do it, for one, I don't know how to put
those id's into an array from the original query, and two, don't know
how to tell it to "get prev of current id from array" or "get next of
current id from array". And I think it might be a bit of an unnecessary
overhead to send that entire array via GET to the display page if you
are only ever going to use 2 values from it, so It would make much more
sense to me to pass the current id, the next id and the previous id for
each "hit" along to the "display" page.

Any ideas on how I could do that?

Thanks





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to