>Hi,
>what about other possibilities to do this ?

>Tom

Other possibilities? Why not just utilize the second argument of the LIMIT function 
with a fairly simple SQL query?

Here's a portion of a script I wrote, modified to be an example on this matter:

<?php

    $articles_display_limit = 5; // set the number of articles to be displayed on each 
page

/*
$article_number sets the position in the database from which the current query results 
will begin from. $article_number is passed to the script as a GET method variable (i.e 
article.php?record_number=5)
*/

    $articles = mysql_query("SELECT * FROM articles
                             LIMIT $article_number,$articles_display_limit");

    $next = $article_number + $articles_display_limit; // next page's starting point
    $prev = $article_number - $articles_display_limit ; // previous page's starting 
point
    $total_number_of_articles = mysql_num_rows(mysql_query("SELECT NULL FROM 
articles"));

    /* display this page's articles*/

 /* determine if a 'Previous' button is required */
if ($prev >= 0) {
    echo '<a href="article.php?article_number=' . $prev . '">Previous</a>' . "\n";
}

 /* determine if a 'Next' button is required */
if ($next < $total_number_of_articles) {
    echo '<a href="article.php?article_number=' . $next . '">Next</a>' . "\n";
}

?>

This should do the trick if I haven't modified too much.
There's a good but a bit messy article about it in PHPBuilder: 
http://phpbuilder.com/columns/rod20000221.php3
The script is much more experienced and advanced than my own.

---
 regards,
  Boaz Amit


> > Hello Pranot,
> >
> > On 16-Jul-01 06:09:33, you wrote:
> >
>
> > >hi.. friends
> > >
> > >i have a database (mysql) in which their r many records. Through PHP i
want
> > > them to display on the page.
> > >
> > > Main requirement is that there should be a NEXT - PREVIOUS facility. So
if
> > > there r 20 records and suppose only 10 should show up on scren at a time,
> > > then a NEXT link should be visible which could show the remaining 10
> > > records.
> > >
> > > Their can be n no. of records.
> > >
> > Maybe you would like to try this PHP class that does exactly what you are
> > asking.
> >
> > http://phpclasses.UpperDesign.com/browse.html/package/130
> >
> >
> > Regards,
> > Manuel Lemos
> >
> > Web Programming Components using PHP Classes.
> > Look at: http://phpclasses.UpperDesign.com/?[EMAIL PROTECTED]
> > --
> > E-mail: [EMAIL PROTECTED]
> > URL: http://www.mlemos.e-na.net/
> > PGP key: http://www.mlemos.e-na.net/ManuelLemos.pgp
> > --
> >





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to