Re: Display Records in Multiple Pages
| From: | Aqua | Date: | Thu, 27 Jun 2002 08:34:30 +0000 |
| Subject: | Re: Display Records in Multiple Pages | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-104114@lists.php.net to get a copy of this message | ||
Thanks! It's working. I got your point after I think about it. Below is my
trial script. Sorry for bothering you guys since I'm a beginner. Thanks
again.
Aqua
......
$sql = "select news_id, news_subj, news_precontent, news_content, news_home
from news order by news_id limit $numInc,2";
.......
<?
$numIncs = $numInc - 2;
echo "<a href=view_news_latest.php3?numInc=$numIncs> Previous</a>";
$numIncs = $numInc + 2;
echo " / <a href=view_news_latest.php3?numInc=$numIncs> Next</a>";
?>
......
----- Original Message -----
From: Justin French <justin@indent.com.au>
To: Aqua <aqua@sas.co.id>
Cc: <php-general@lists.php.net>
Sent: Thursday, June 27, 2002 3:09 PM
Subject: Re: [PHP] Display Records in Multiple Pages
> well, establish how many you want per page ($perpage = 25).
>
> so your first limit will obviously be 0 and 25.
>
> since the offset is 0, there is no back button page 1, and the forward
> button is something like view.php?offset=25.
>
> then on subsequent pages, you use the $offset and $perpage to create the
> LIMIT statement. the links are created by taking the $offset (currently
25)
> and minusing/adding the $perpage figure.
>
> <A HREF="view.php?offset=<? echo $offest - $perpage; ?>">back</a>
> <A HREF="view.php?offset=<? echo $offest + $perpage;
> ?>">forward</a>
>
> Then you only have to watch out to make sure that the forward button isn't
> there on the last page of results.
>
> It's hard to explain, easy to implement. Just sit down and think it
> through.
>
>
> Justin French
>
>
>
>
> on 27/06/02 5:55 PM, Aqua (aqua@sas.co.id) wrote:
>
> > The LIMIT function is working, thanks. But how to generate back /
forward
> > links using html/php? Thanks for your help.
> >
> > Aqua
> >
> > ----- Original Message -----
> > From: Justin French <justin@indent.com.au>
> > To: Aqua <aqua@sas.co.id>; <php-general@lists.php.net>
> > Sent: Thursday, June 27, 2002 1:56 PM
> > Subject: Re: [PHP] Display Records in Multiple Pages
> >
> >
> >> Use the LIMIT function in your SELECT query... check out the MySQL
> > manual...
> >> and then generate back / forward links depending on your current
offset.
> > It
> >> should be expandable to 1000 records without any mods to the code.
> >>
> >> Justin French
> >>
> >>
> >>
> >> on 27/06/02 4:54 PM, Aqua (aqua@sas.co.id) wrote:
> >>
> >>> I have 100 records in mySQL database and I need to display them in my
> > web page
> >>> using php and html. How to display them in multiple pages? Each page
> > must
> >>> contain 25 records. Does anyone know how to do it other than create 4
> > pages
> >>> and manually list the records there? or maybe point me some reference
> > please.
> >>> Your help will be much appreciated. Thanks!
> >>>
> >>> Aqua
> >>>
> >>
> >>
> >
> >
>
>