By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,007 Members | 1,066 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,007 IT Pros & Developers. It's quick & easy.

Mysql: next and previous

P: n/a
Does exist a next prev function in PHP/Mysql. I've a website with returns
lot of records (say about 200). The user may browse trough the list or
returned records, but he has to click the record result then click back's
browser in order to see the next record. I'd like to provide a "see next"
and "see previous" record in the details itself. How to do so ?

Bob
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Bob Bedford wrote:
Does exist a next prev function in PHP/Mysql. I've a website with
returns lot of records (say about 200). The user may browse trough the
list or returned records, but he has to click the record result then
click back's browser in order to see the next record. I'd like to
provide a "see next" and "see previous" record in the details itself.
How to do so ?

Bob

Hi,

Try out the pear(pear.php.net) Pager package.

Hope to have helped ;-)
Jul 17 '05 #2

P: n/a
Bob Bedford wrote:
Does exist a next prev function in PHP/Mysql. I've a website with
returns lot of records (say about 200). The user may browse trough the
list or returned records, but he has to click the record result then
click back's browser in order to see the next record. I'd like to
provide a "see next" and "see previous" record in the details itself.
How to do so ?

Bob


In a Relational Data Base Management System the data is stored
at random and order is imparted by indices. As a result there
is no valid previous or next in the database.

If you want to use previous and next create an additional column
in your table, use it to hold an auto-increment value, and index
on the value. You will then have to write your own functions
to retrieve the next and previous rows from your table.
Assuming that you increment by one and that the table is fully
populated you might use something that starts like:

function get_next(id) {
$get_id = $id + 1;
SQL = "SELECT * FROM my_table
WHERE table_id = '$get_id'";

(the rest is left as an exercise for the reader)
Jul 17 '05 #3

P: n/a
On Tue, 2 Nov 2004 13:55:20 +0100, "Bob Bedford"
<be******@YouKnowWhatToDoHerehotmail.com> wrote:
Does exist a next prev function in PHP/Mysql. I've a website with returns
lot of records (say about 200). The user may browse trough the list or
returned records, but he has to click the record result then click back's
browser in order to see the next record. I'd like to provide a "see next"
and "see previous" record in the details itself. How to do so ?

Bob

You can specify the number of records retured and the offset in the
MySQL query. So, for instance, if you wanted ten records at a time you
could do something like:
SELECT * FROM table WHERE condition ORDER BY field LIMIT 10,$x

where $x is the offset, then make the back/next links increment or
decrement the value of $x

BTW, I can never remember off the top of my head which order the LIMIT
clause goes in, so it might be as above, or it might be LIMIT $x,10

hth

C

Jul 17 '05 #4

P: n/a
Bob Bedford wrote:
Does exist a next prev function in PHP/Mysql. I've a website with returns
lot of records (say about 200). The user may browse trough the list or
returned records, but he has to click the record result then click back's
browser in order to see the next record. I'd like to provide a "see next"
and "see previous" record in the details itself. How to do so ?

Bob


You'll need a unique sort combination followed by the LIMIT keyword.

HTH

C.
Jul 17 '05 #5

P: n/a
Take a look at http://www.tonymarston.co.uk/php-mysql/pagination.html

--
Tony Marston

http://www.tonymarston.net
"Bob Bedford" <be******@YouKnowWhatToDoHerehotmail.com> wrote in message
news:41***********************@news.sunrise.ch...
Does exist a next prev function in PHP/Mysql. I've a website with returns
lot of records (say about 200). The user may browse trough the list or
returned records, but he has to click the record result then click back's
browser in order to see the next record. I'd like to provide a "see next"
and "see previous" record in the details itself. How to do so ?

Bob

Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.