RE: [PEAR] Pager_Sliding DB/Templates example
| From: | Joseph Blythe | Date: | Thu, 24 Jul 2003 00:26:36 +0000 |
| Subject: | RE: [PEAR] Pager_Sliding DB/Templates example | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-6780@lists.php.net to get a copy of this message | ||
Thankyou guys, I thought it would be a little more straight forward, I guess
DB_Pager is the easiest way of paginating database record sets hence the
'DB' in its name :) I will try out the tricky way when I get more time (have
a tight deadline ack!) for now I guess DB_Pager works quite well for me.
Many Thanks,
Joseph
> -----Original Message-----
> From: alexander.merz@web.de [mailto:alexander.merz@web.de]
> Sent: Wednesday, 23 July 2003 9:13 PM
> To: Joseph Blythe
> Cc: Pear-General (E-mail)
> Subject: Re: [PEAR] Pager_Sliding DB/Templates example
>
>
> Joseph Blythe wrote:
>
> > Has anyone got any examples of using Pager_sliding with DB
> and templates, I
> > have used DB_Pager but cant seem to get Pager_Sliding to
> function properly ?
>
> There is a tricky way:
> - fetch the number of resultsets with count
> - create an array of this size with empty entries
> - create an DB_Pager instance
> - fetch the data and pass them to the array
> - create Pager_Sliding with the array
> - display the stuff
>
> practical:
> - you have ten result sets, you want to display one per page.
> -> $data=array_fill(0,10,'');
>
> - for the first page: $from=0 $limit=1 $numrows=10
> - DB_Pager returns the first result set
> -> passed it to the first array entry $data[$from]=...
>
> - create DB_Pager with perPage=$limit itemData=$data
> - display the stuff
>
>
> for every further page you do the same with on different:
> - check for $_GET['pageID'] (else display the first page)
> -> $from = ($_GET['pageID']-1)*$limit
> - ie for the second page $data should looks like this:
>
> array('',value,'','','','','','','','')
> for #3
>
> array('','',value,'','','','','','','')
> ...
>
> HTH
>
>
>
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php